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