00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027 #ifndef SHGENERIC_HPP
00028 #define SHGENERIC_HPP
00029
00030 #include "ShVariableType.hpp"
00031 #include "ShDataType.hpp"
00032 #include "ShVariable.hpp"
00033 #include "ShVariant.hpp"
00034
00035 namespace SH {
00036
00037 class ShProgram;
00038
00063 template<int N, typename T>
00064 class ShGeneric : public ShVariable
00065 {
00066 public:
00067 typedef T storage_type;
00068 static const ShValueType value_type = ShStorageTypeInfo<T>::value_type;
00069 typedef typename ShHostType<T>::type host_type;
00070 typedef typename ShMemType<T>::type mem_type;
00071 static const int typesize = N;
00072
00073 typedef ShDataVariant<T, SH_HOST> VariantType;
00074 typedef ShPointer<VariantType> VariantTypePtr;
00075 typedef ShPointer<const VariantType> VariantTypeCPtr;
00076
00077
00078 ShGeneric(const ShVariableNodePtr& node, ShSwizzle swizzle, bool neg);
00079 ~ShGeneric();
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 template<typename T2>
00091 ShGeneric(const ShGeneric<N, T2> &other);
00092
00093
00094
00095
00096
00097 ShGeneric& operator=(const ShGeneric& other);
00098
00099 template<typename T2>
00100 ShGeneric& operator=(const ShGeneric<N, T2>& other);
00101
00102 ShGeneric& operator=(const ShProgram& other);
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 template<typename T2>
00217 ShGeneric& operator+=(const ShGeneric<1, T2>& right);
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 ShGeneric& operator+=(host_type);
00232 ShGeneric& operator-=(host_type);
00233 ShGeneric& operator*=(host_type);
00234 ShGeneric& operator/=(host_type);
00235 ShGeneric& operator%=(host_type);
00236
00237 ShGeneric operator-() const;
00238
00239 ShGeneric operator()() const;
00240 ShGeneric<1, T> operator()(int) const;
00241 ShGeneric<1, T> operator[](int) const;
00242 ShGeneric<2, T> operator()(int, int) const;
00243 ShGeneric<3, T> operator()(int, int, int) const;
00244 ShGeneric<4, T> operator()(int, int, int, int) const;
00245
00247 void range(host_type low, host_type high);
00248
00249 VariantType lowBound() const;
00250 host_type lowBound(int index) const;
00251
00252 VariantType highBound() const;
00253 host_type highBound(int index) const;
00254
00255
00256 template<int N2>
00257 ShGeneric<N2, T> swiz(int indices[]) const;
00258
00260 void getValues(host_type dest[]) const;
00261 host_type getValue(int index) const;
00262
00265 void setValue(int index, const host_type &value);
00266 void setValues(const host_type values[]);
00267
00268 protected:
00269 ShGeneric(const ShVariableNodePtr& node);
00270
00271 };
00272
00273 }
00274
00275
00276
00277 #ifndef SH_DO_NOT_INCLUDE_GENERIC_IMPL
00278 #include "ShGenericImpl.hpp"
00279 #endif
00280
00281 #endif