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 SHSWIZZLE_HPP
00028 #define SHSWIZZLE_HPP
00029
00030 #include <iosfwd>
00031
00032 #include "ShDllExport.hpp"
00033 #include "ShException.hpp"
00034
00035 namespace SH {
00036
00056 class
00057 SH_DLLEXPORT
00058 ShSwizzle {
00059 public:
00060
00061
00062 ShSwizzle();
00063
00065 ShSwizzle(int srcSize);
00067 ShSwizzle(int srcSize, int i0);
00069 ShSwizzle(int srcSize, int i0, int i1);
00071 ShSwizzle(int srcSize, int i0, int i1, int i2);
00073 ShSwizzle(int srcSize, int i0, int i1, int i2, int i3);
00075 ShSwizzle(int srcSize, int size, int* indices);
00076
00077 ShSwizzle(const ShSwizzle& other);
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