Home | History | Annotate | Download | only in detail
      1 ///////////////////////////////////////////////////////////////////////////////////
      2 /// OpenGL Mathematics (glm.g-truc.net)
      3 ///
      4 /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
      5 /// Permission is hereby granted, free of charge, to any person obtaining a copy
      6 /// of this software and associated documentation files (the "Software"), to deal
      7 /// in the Software without restriction, including without limitation the rights
      8 /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      9 /// copies of the Software, and to permit persons to whom the Software is
     10 /// furnished to do so, subject to the following conditions:
     11 ///
     12 /// The above copyright notice and this permission notice shall be included in
     13 /// all copies or substantial portions of the Software.
     14 ///
     15 /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16 /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17 /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     18 /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19 /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     20 /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     21 /// THE SOFTWARE.
     22 ///
     23 /// @ref core
     24 /// @file glm/core/type_gentype.hpp
     25 /// @date 2008-10-05 / 2011-06-15
     26 /// @author Christophe Riccio
     27 ///////////////////////////////////////////////////////////////////////////////////
     28 
     29 #ifndef glm_core_type_gentype
     30 #define glm_core_type_gentype
     31 
     32 namespace glm
     33 {
     34 	enum profile
     35 	{
     36 		nice,
     37 		fast,
     38 		simd
     39 	};
     40 
     41 	typedef std::size_t sizeType;
     42 
     43 namespace detail
     44 {
     45 	template
     46 	<
     47 		typename VALTYPE,
     48 		template <typename> class TYPE
     49 	>
     50 	struct genType
     51 	{
     52 	public:
     53 		enum ctor{null};
     54 
     55 		typedef VALTYPE value_type;
     56 		typedef VALTYPE & value_reference;
     57 		typedef VALTYPE * value_pointer;
     58 		typedef VALTYPE const * value_const_pointer;
     59 		typedef TYPE<bool> bool_type;
     60 
     61 		typedef sizeType size_type;
     62 		static bool is_vector();
     63 		static bool is_matrix();
     64 
     65 		typedef TYPE<VALTYPE> type;
     66 		typedef TYPE<VALTYPE> * pointer;
     67 		typedef TYPE<VALTYPE> const * const_pointer;
     68 		typedef TYPE<VALTYPE> const * const const_pointer_const;
     69 		typedef TYPE<VALTYPE> * const pointer_const;
     70 		typedef TYPE<VALTYPE> & reference;
     71 		typedef TYPE<VALTYPE> const & const_reference;
     72 		typedef TYPE<VALTYPE> const & param_type;
     73 
     74 		//////////////////////////////////////
     75 		// Address (Implementation details)
     76 
     77 		value_const_pointer value_address() const{return value_pointer(this);}
     78 		value_pointer value_address(){return value_pointer(this);}
     79 
     80 	//protected:
     81 	//	enum kind
     82 	//	{
     83 	//		GEN_TYPE,
     84 	//		VEC_TYPE,
     85 	//		MAT_TYPE
     86 	//	};
     87 
     88 	//	typedef typename TYPE::kind kind;
     89 	};
     90 
     91 	template
     92 	<
     93 		typename VALTYPE,
     94 		template <typename> class TYPE
     95 	>
     96 	bool genType<VALTYPE, TYPE>::is_vector()
     97 	{
     98 		return true;
     99 	}
    100 /*
    101 	template <typename valTypeT, unsigned int colT, unsigned int rowT, profile proT = nice>
    102 	class base
    103 	{
    104 	public:
    105 		//////////////////////////////////////
    106 		// Traits
    107 
    108 		typedef sizeType							size_type;
    109 		typedef valTypeT							value_type;
    110 
    111 		typedef base<value_type, colT, rowT>		class_type;
    112 
    113 		typedef base<bool, colT, rowT>				bool_type;
    114 		typedef base<value_type, rowT, 1>			col_type;
    115 		typedef base<value_type, colT, 1>			row_type;
    116 		typedef base<value_type, rowT, colT>		transpose_type;
    117 
    118 		static size_type							col_size();
    119 		static size_type							row_size();
    120 		static size_type							value_size();
    121 		static bool									is_scalar();
    122 		static bool									is_vector();
    123 		static bool									is_matrix();
    124 
    125 	private:
    126 		// Data
    127 		col_type value[colT];
    128 
    129 	public:
    130 		//////////////////////////////////////
    131 		// Constructors
    132 		base();
    133 		base(class_type const & m);
    134 
    135 		explicit base(T const & x);
    136 		explicit base(value_type const * const x);
    137 		explicit base(col_type const * const x);
    138 
    139 		//////////////////////////////////////
    140 		// Conversions
    141 		template <typename vU, uint cU, uint rU, profile pU>
    142 		explicit base(base<vU, cU, rU, pU> const & m);
    143 
    144 		//////////////////////////////////////
    145 		// Accesses
    146 		col_type& operator[](size_type i);
    147 		col_type const & operator[](size_type i) const;
    148 
    149 		//////////////////////////////////////
    150 		// Unary updatable operators
    151 		class_type& operator=  (class_type const & x);
    152 		class_type& operator+= (T const & x);
    153 		class_type& operator+= (class_type const & x);
    154 		class_type& operator-= (T const & x);
    155 		class_type& operator-= (class_type const & x);
    156 		class_type& operator*= (T const & x);
    157 		class_type& operator*= (class_type const & x);
    158 		class_type& operator/= (T const & x);
    159 		class_type& operator/= (class_type const & x);
    160 		class_type& operator++ ();
    161 		class_type& operator-- ();
    162 	};
    163 */
    164 
    165 	//template <typename T>
    166 	//struct traits
    167 	//{
    168 	//	static const bool is_signed = false;
    169 	//	static const bool is_float = false;
    170 	//	static const bool is_vector = false;
    171 	//	static const bool is_matrix = false;
    172 	//	static const bool is_genType = false;
    173 	//	static const bool is_genIType = false;
    174 	//	static const bool is_genUType = false;
    175 	//};
    176 
    177 	//template <>
    178 	//struct traits<half>
    179 	//{
    180 	//	static const bool is_float = true;
    181 	//	static const bool is_genType = true;
    182 	//};
    183 
    184 	//template <>
    185 	//struct traits<float>
    186 	//{
    187 	//	static const bool is_float = true;
    188 	//	static const bool is_genType = true;
    189 	//};
    190 
    191 	//template <>
    192 	//struct traits<double>
    193 	//{
    194 	//	static const bool is_float = true;
    195 	//	static const bool is_genType = true;
    196 	//};
    197 
    198 	//template <typename genType>
    199 	//struct desc
    200 	//{
    201 	//	typedef genType							type;
    202 	//	typedef genType *						pointer;
    203 	//	typedef genType const*					const_pointer;
    204 	//	typedef genType const *const			const_pointer_const;
    205 	//	typedef genType *const					pointer_const;
    206 	//	typedef genType &						reference;
    207 	//	typedef genType const&					const_reference;
    208 	//	typedef genType const&					param_type;
    209 
    210 	//	typedef typename genType::value_type	value_type;
    211 	//	typedef typename genType::size_type		size_type;
    212 	//	static const typename size_type			value_size;
    213 	//};
    214 
    215 	//template <typename genType>
    216 	//const typename desc<genType>::size_type desc<genType>::value_size = genType::value_size();
    217 
    218 }//namespace detail
    219 }//namespace glm
    220 
    221 //#include "type_gentype.inl"
    222 
    223 #endif//glm_core_type_gentype
    224