00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024 #ifndef SHGENERIC_HPP
00025 #define SHGENERIC_HPP
00026
00027 #include "ShVariableType.hpp"
00028 #include "ShDataType.hpp"
00029 #include "ShVariable.hpp"
00030 #include "ShVariant.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 typedef T storage_type;
00065 static const ShValueType value_type = ShStorageTypeInfo<T>::value_type;
00066 typedef typename ShHostType<T>::type host_type;
00067 typedef typename ShMemType<T>::type mem_type;
00068 static const int typesize = N;
00069
00070 typedef ShDataVariant<T, SH_HOST> VariantType;
00071 typedef ShPointer<VariantType> VariantTypePtr;
00072 typedef ShPointer<const VariantType> VariantTypeCPtr;
00073
00074
00075 ShGeneric(const ShVariableNodePtr& node, ShSwizzle swizzle, bool neg);
00076 ~ShGeneric();
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 template<typename T2>
00088 ShGeneric(const ShGeneric<N, T2> &other);
00089
00090
00091
00092
00093
00094 ShGeneric& operator=(const ShGeneric& other);
00095
00096 template<typename T2>
00097 ShGeneric& operator=(const ShGeneric<N, T2>& other);
00098
00099 ShGeneric& operator=(const ShProgram& other);
00100
00101 ShGeneric& operator++();
00102 ShGeneric& operator--();
00103
00104 template<typename T2>
00105 ShGeneric& operator+=(const ShGeneric<N, T2>& right);
00106
00107 template<typename T2>
00108 ShGeneric& operator-=(const ShGeneric<N, T2>& right);
00109
00110 template<typename T2>
00111 ShGeneric& operator*=(const ShGeneric<N, T2>& right);
00112
00113 template<typename T2>
00114 ShGeneric& operator/=(const ShGeneric<N, T2>& right);
00115
00116 template<typename T2>
00117 ShGeneric& operator%=(const ShGeneric<N, T2>& right);
00118
00119 template<typename T2>
00120 ShGeneric& operator+=(const ShGeneric<1, T2>& right);
00121
00122 template<typename T2>
00123 ShGeneric& operator-=(const ShGeneric<1, T2>& right);
00124
00125 template<typename T2>
00126 ShGeneric& operator*=(const ShGeneric<1, T2>& right);
00127
00128 template<typename T2>
00129 ShGeneric& operator/=(const ShGeneric<1, T2>& right);
00130
00131 template<typename T2>
00132 ShGeneric& operator%=(const ShGeneric<1, T2>& right);
00133
00134 ShGeneric& operator+=(host_type);
00135 ShGeneric& operator-=(host_type);
00136 ShGeneric& operator*=(host_type);
00137 ShGeneric& operator/=(host_type);
00138 ShGeneric& operator%=(host_type);
00139
00140 ShGeneric operator-() const;
00141
00142 ShGeneric operator()() const;
00143 ShGeneric<1, T> operator()(int) const;
00144 ShGeneric<1, T> operator[](int) const;
00145 ShGeneric<2, T> operator()(int, int) const;
00146 ShGeneric<3, T> operator()(int, int, int) const;
00147 ShGeneric<4, T> operator()(int, int, int, int) const;
00148
00150 void range(host_type low, host_type high);
00151
00152 VariantType lowBound() const;
00153 host_type lowBound(int index) const;
00154
00155 VariantType highBound() const;
00156 host_type highBound(int index) const;
00157
00158
00159 template<int N2>
00160 ShGeneric<N2, T> swiz(int indices[]) const;
00161
00163 void getValues(host_type dest[]) const;
00164 host_type getValue(int index) const;
00165
00168 void setValue(int index, const host_type &value);
00169 void setValues(const host_type values[]);
00170
00171
00172 protected:
00173 ShGeneric(const ShVariableNodePtr& node);
00174
00175 };
00176
00177 template<typename T>
00178 class ShGeneric<1, T> : public ShVariable
00179 {
00180 public:
00181 typedef T storage_type;
00182 static const ShValueType value_type = ShStorageTypeInfo<T>::value_type;
00183 typedef typename ShHostType<T>::type host_type;
00184 typedef typename ShMemType<T>::type mem_type;
00185 static const int typesize = 1;
00186
00187 typedef ShDataVariant<T, SH_HOST> VariantType;
00188 typedef ShPointer<VariantType> VariantTypePtr;
00189 typedef ShPointer<const VariantType> VariantTypeCPtr;
00190
00191
00192 ShGeneric(const ShVariableNodePtr& node, ShSwizzle swizzle, bool neg);
00193 ~ShGeneric();
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 template<typename T2>
00205 ShGeneric(const ShGeneric<1, T2> &other);
00206
00207
00208 ShGeneric& operator=(const ShGeneric<1, T>& other);
00209
00210 template<typename T2>
00211 ShGeneric& operator=(const ShGeneric<1, T2>& other);
00212
00213 ShGeneric& operator=(host_type);
00214 ShGeneric& operator=(const ShProgram& other);
00215
00216 ShGeneric& operator++();
00217 ShGeneric& operator--();
00218
00219 template<typename T2>
00220 ShGeneric& operator+=(const ShGeneric<1, T2>& right);
00221
00222 template<typename T2>
00223 ShGeneric& operator-=(const ShGeneric<1, T2>& right);
00224
00225 template<typename T2>
00226 ShGeneric& operator*=(const ShGeneric<1, T2>& right);
00227
00228 template<typename T2>
00229 ShGeneric& operator/=(const ShGeneric<1, T2>& right);
00230
00231 template<typename T2>
00232 ShGeneric& operator%=(const ShGeneric<1, T2>& right);
00233
00234 ShGeneric& operator+=(host_type);
00235 ShGeneric& operator-=(host_type);
00236 ShGeneric& operator*=(host_type);
00237 ShGeneric& operator/=(host_type);
00238 ShGeneric& operator%=(host_type);
00239
00240 ShGeneric operator-() const;
00241
00242 ShGeneric operator()() const;
00243 ShGeneric<1, T> operator()(int) const;
00244 ShGeneric<1, T> operator[](int) const;
00245 ShGeneric<2, T> operator()(int, int) const;
00246 ShGeneric<3, T> operator()(int, int, int) const;
00247 ShGeneric<4, T> operator()(int, int, int, int) const;
00248
00250 void range(host_type low, host_type high);
00251
00252 VariantType lowBound() const;
00253 host_type lowBound(int index) const;
00254
00255 VariantType highBound() const;
00256 host_type highBound(int index) const;
00257
00258
00259 template<int N2>
00260 ShGeneric<N2, T> swiz(int indices[]) const;
00261
00263 void getValues(host_type dest[]) const;
00264 host_type getValue(int index) const;
00265
00268 void setValue(int index, const host_type &value);
00269 void setValues(const host_type values[]);
00270
00271 protected:
00272 ShGeneric(const ShVariableNodePtr& node);
00273
00274 };
00275
00276 }
00277
00278
00279
00280 #ifndef SH_DO_NOT_INCLUDE_GENERIC_IMPL
00281 #include "ShGenericImpl.hpp"
00282 #endif
00283
00284 #endif