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