Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ShGeneric.hpp

00001 // Sh: A GPU metaprogramming language. 00002 // 00003 // Copyright (c) 2003 University of Waterloo Computer Graphics Laboratory 00004 // Project administrator: Michael D. McCool 00005 // Authors: Zheng Qin, Stefanus Du Toit, Kevin Moule, Tiberiu S. Popa, 00006 // Michael D. McCool 00007 // 00008 // This software is provided 'as-is', without any express or implied 00009 // warranty. In no event will the authors be held liable for any damages 00010 // arising from the use of this software. 00011 // 00012 // Permission is granted to anyone to use this software for any purpose, 00013 // including commercial applications, and to alter it and redistribute it 00014 // freely, subject to the following restrictions: 00015 // 00016 // 1. The origin of this software must not be misrepresented; you must 00017 // not claim that you wrote the original software. If you use this 00018 // software in a product, an acknowledgment in the product documentation 00019 // would be appreciated but is not required. 00020 // 00021 // 2. Altered source versions must be plainly marked as such, and must 00022 // not be misrepresented as being the original software. 00023 // 00024 // 3. This notice may not be removed or altered from any source 00025 // distribution. 00027 #ifndef SHGENERIC_HPP 00028 #define SHGENERIC_HPP 00029 00030 #include "ShVariable.hpp" 00031 00032 namespace SH { 00033 00034 class ShProgram; 00035 00060 template<int N, typename T> 00061 class ShGeneric : public ShVariable 00062 { 00063 public: 00064 ShGeneric(const ShVariableNodePtr& node, ShSwizzle swizzle, bool neg); 00065 ~ShGeneric(); 00066 00067 ShGeneric& operator=(const ShGeneric& other); 00068 ShGeneric& operator=(const ShProgram& other); 00069 00070 ShGeneric& operator+=(const ShGeneric& right); 00071 ShGeneric& operator-=(const ShGeneric& right); 00072 ShGeneric& operator*=(const ShGeneric& right); 00073 ShGeneric& operator/=(const ShGeneric& right); 00074 ShGeneric& operator%=(const ShGeneric& right); 00075 ShGeneric& operator+=(const ShGeneric<1, T>& right); 00076 ShGeneric& operator-=(const ShGeneric<1, T>& right); 00077 ShGeneric& operator*=(const ShGeneric<1, T>& right); 00078 ShGeneric& operator/=(const ShGeneric<1, T>& right); 00079 ShGeneric& operator%=(const ShGeneric<1, T>& right); 00080 ShGeneric& operator+=(T); 00081 ShGeneric& operator-=(T); 00082 ShGeneric& operator*=(T); 00083 ShGeneric& operator/=(T); 00084 ShGeneric& operator%=(T); 00085 00086 ShGeneric operator-() const; 00087 00088 ShGeneric operator()() const; 00089 ShGeneric<1, T> operator()(int) const; 00090 ShGeneric<1, T> operator[](int) const; 00091 ShGeneric<2, T> operator()(int, int) const; 00092 ShGeneric<3, T> operator()(int, int, int) const; 00093 ShGeneric<4, T> operator()(int, int, int, int) const; 00094 00095 // Arbitrary Swizzle 00096 template<int N2> 00097 ShGeneric<N2, T> swiz(int indices[]) const; 00098 00099 typedef T ValueType; 00100 static const int typesize = N; 00101 00102 protected: 00103 ShGeneric(const ShVariableNodePtr& node); 00104 }; 00105 00106 template<typename T> 00107 class ShGeneric<1, T> : public ShVariable 00108 { 00109 public: 00110 ShGeneric(const ShVariableNodePtr& node, ShSwizzle swizzle, bool neg); 00111 ~ShGeneric(); 00112 00113 ShGeneric& operator=(const ShGeneric& other); 00114 ShGeneric& operator=(T); 00115 ShGeneric& operator=(const ShProgram& other); 00116 00117 ShGeneric& operator+=(const ShGeneric& right); 00118 ShGeneric& operator-=(const ShGeneric& right); 00119 ShGeneric& operator*=(const ShGeneric& right); 00120 ShGeneric& operator/=(const ShGeneric& right); 00121 ShGeneric& operator%=(const ShGeneric& right); 00122 ShGeneric& operator+=(T); 00123 ShGeneric& operator-=(T); 00124 ShGeneric& operator*=(T); 00125 ShGeneric& operator/=(T); 00126 ShGeneric& operator%=(T); 00127 00128 ShGeneric operator-() const; 00129 00130 ShGeneric operator()() const; 00131 ShGeneric<1, T> operator()(int) const; 00132 ShGeneric<1, T> operator[](int) const; 00133 ShGeneric<2, T> operator()(int, int) const; 00134 ShGeneric<3, T> operator()(int, int, int) const; 00135 ShGeneric<4, T> operator()(int, int, int, int) const; 00136 00137 // Arbitrary Swizzle 00138 template<int N2> 00139 ShGeneric<N2, T> swiz(int indices[]) const; 00140 00141 typedef T ValueType; 00142 static const int typesize = 1; 00143 00144 protected: 00145 ShGeneric(const ShVariableNodePtr& node); 00146 }; 00147 00148 } 00149 00150 // This is a hack for ShAttrib.hpp in particular. 00151 // A little dirty, but it works well. 00152 #ifndef SH_DO_NOT_INCLUDE_GENERIC_IMPL 00153 #include "ShGenericImpl.hpp" 00154 #endif 00155 00156 #endif

Generated on Mon Oct 18 14:17:39 2004 for Sh by doxygen 1.3.7