00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024 #ifndef SHSWIZZLE_HPP
00025 #define SHSWIZZLE_HPP
00026
00027 #include <iosfwd>
00028
00029 #include "ShDllExport.hpp"
00030 #include "ShException.hpp"
00031
00032 namespace SH {
00033
00053 class
00054 SH_DLLEXPORT
00055 ShSwizzle {
00056 public:
00057
00058
00059 ShSwizzle();
00060
00062 ShSwizzle(int srcSize);
00064 ShSwizzle(int srcSize, int i0);
00066 ShSwizzle(int srcSize, int i0, int i1);
00068 ShSwizzle(int srcSize, int i0, int i1, int i2);
00070 ShSwizzle(int srcSize, int i0, int i1, int i2, int i3);
00072 ShSwizzle(int srcSize, int size, int* indices);
00073
00074 ShSwizzle(const ShSwizzle& other);
00075
00076
00077 ShSwizzle(const ShSwizzle& other, int n);
00078 ~ShSwizzle();
00079
00080 ShSwizzle& operator=(const ShSwizzle& other);
00081
00084 ShSwizzle& operator*=(const ShSwizzle& other);
00085
00087 ShSwizzle operator*(const ShSwizzle& other) const;
00088
00090 int size() const { return m_size; }
00091
00095 int operator[](int i) const;
00096
00098 bool identity() const;
00099
00101 bool operator==(const ShSwizzle& other) const;
00102
00103 private:
00104
00105 void copy(const ShSwizzle &other, bool islocal);
00106
00107
00108 void checkSrcSize(int index);
00109
00110
00111
00112 bool alloc();
00113
00114
00115 void dealloc();
00116
00117
00118 bool local() const;
00119
00120
00121 int idswiz() const;
00122
00123
00124 int m_srcSize;
00125 int m_size;
00126
00127
00128
00129
00130 union {
00131 unsigned char local[4];
00132 int intval;
00133 int* ptr;
00134 } m_index;
00135
00136 friend SH_DLLEXPORT std::ostream& operator<<(std::ostream& out, const ShSwizzle& swizzle);
00137 };
00138
00141 class
00142 SH_DLLEXPORT ShSwizzleException : public ShException
00143 {
00144 public:
00145 ShSwizzleException(const ShSwizzle& s, int idx, int size);
00146 };
00147
00148 }
00149
00150 #include "ShSwizzleImpl.hpp"
00151
00152 #endif