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
00026
00027
00028
00029
00030 #ifndef __ARRAY_OWN_1_H__
00031 #define __ARRAY_OWN_1_H__
00032
00033 #include "arrayWrap1.h"
00034 #include <assert.h>
00035
00036 namespace gutz {
00037
00038
00039
00040
00041
00042 template <class T>
00043 class arrayOwn1 : public arrayWrap1<T>
00044 {
00045 public:
00046
00047 arrayOwn1();
00048 arrayOwn1( int s, T v );
00049 arrayOwn1( int s, const T* v);
00050 arrayOwn1( const arrayWrap1<T>& a );
00051
00052 arrayOwn1( const arrayOwn1<T>& a );
00053 arrayOwn1<T>& operator=( const arrayOwn1<T>& a );
00054
00055 ~arrayOwn1() {killData();}
00056
00057
00058
00059
00060 void transfer( int s, T* v, bool killWithDelete );
00061
00062 private:
00063 void initVal (T v);
00064 void initData (const T* v);
00065 };
00066
00067
00068
00069
00070
00071
00072
00073 template <class T>
00074 arrayOwn1<T>::arrayOwn1 ()
00075 : arrayWrap1<T>()
00076 {}
00077
00078 template <class T>
00079 arrayOwn1<T>::arrayOwn1 (int s, T v)
00080 : arrayWrap1<T>(s,NULL)
00081 {
00082 arrayBase<T>::initValOwn( v );
00083 }
00084
00085 template <class T>
00086 arrayOwn1<T>::arrayOwn1 (int s, const T* v)
00087 : arrayWrap1<T>(s,NULL)
00088 {
00089 arrayBase<T>::initDataOwn( v );
00090 }
00091
00092 template <class T>
00093 arrayOwn1<T>::arrayOwn1 ( const arrayWrap1<T>& a)
00094 : arrayWrap1<T>(a.size(),NULL)
00095 {
00096 arrayBase<T>::initDataOwn(a.data());
00097 }
00098
00099
00100 template <class T>
00101 arrayOwn1<T>::arrayOwn1( const arrayOwn1<T>& a ) : arrayWrap1<T>(a)
00102 {
00103 arrayBase<T>::initDataOwn(a.mData);
00104 }
00105
00106
00107 template <class T>
00108 arrayOwn1<T>& arrayOwn1<T>::operator=( const arrayOwn1<T>& a )
00109 {
00110 if( &a != this ) {
00111
00112 if( (mSize != a.size() ) ||
00113 (dim(0) != a.dim(0)) ) {
00114 killData();
00115 arrayWrap1<T>::operator=(a);
00116 arrayBase<T>::allocDataOwn();
00117 }
00118 arrayBase<T>::copyDataOwn(a.mData);
00119 }
00120 return *this;
00121 }
00122
00123
00124
00125 template <class T>
00126 void arrayOwn1<T>::transfer( int s, T* v, bool killWithDelete )
00127 {
00128 killData();
00129
00130 int sizes[1];
00131 sizes[0] = s;
00132 set(1, sizes, v);
00133
00134 mKillWithDelete = killWithDelete;
00135 }
00136
00137
00138
00139
00140
00141
00142 typedef arrayOwn1<char> arrayo1c;
00143 typedef arrayOwn1<uchar> arrayo1uc;
00144 typedef arrayOwn1<char> arrayo1b;
00145 typedef arrayOwn1<uchar> arrayo1ub;
00146 typedef arrayOwn1<short> arrayo1s;
00147 typedef arrayOwn1<ushort> arrayo1us;
00148 typedef arrayOwn1<int> arrayo1i;
00149 typedef arrayOwn1<uint> arrayo1ui;
00150 typedef arrayOwn1<long> arrayo1l;
00151 typedef arrayOwn1<ulong> arrayo1ul;
00152 typedef arrayOwn1<llong> arrayo1ll;
00153 typedef arrayOwn1<ullong> arrayo1ull;
00154 typedef arrayOwn1<float> arrayo1f;
00155 typedef arrayOwn1<double> arrayo1d;
00156
00157 #ifdef USING_MATHGUTZ
00158 typedef arrayOwn1<vec2ub> arrayo1v2ub;
00159 typedef arrayOwn1<vec2i> arrayo1v2i;
00160 typedef arrayOwn1<vec2ui> arrayo1v2ui;
00161 typedef arrayOwn1<vec2f> arrayo1v2f;
00162
00163 typedef arrayOwn1<vec3ub> arrayo1v3ub;
00164 typedef arrayOwn1<vec3i> arrayo1v3i;
00165 typedef arrayOwn1<vec3ui> arrayo1v3ui;
00166 typedef arrayOwn1<vec3f> arrayo1v3f;
00167
00168 typedef arrayOwn1<vec4ub> arrayo1v4ub;
00169 typedef arrayOwn1<vec4i> arrayo1v4i;
00170 typedef arrayOwn1<vec4ui> arrayo1v4ui;
00171 typedef arrayOwn1<vec4f> arrayo1v4f;
00172
00173 typedef arrayOwn1<mat2ub> arrayo1m2ub;
00174 typedef arrayOwn1<mat2i> arrayo1m2i;
00175 typedef arrayOwn1<mat2ui> arrayo1m2ui;
00176 typedef arrayOwn1<mat2f> arrayo1m2f;
00177
00178 typedef arrayOwn1<mat3ub> arrayo1m3ub;
00179 typedef arrayOwn1<mat3i> arrayo1m3i;
00180 typedef arrayOwn1<mat3ui> arrayo1m3ui;
00181 typedef arrayOwn1<mat3f> arrayo1m3f;
00182
00183 typedef arrayOwn1<mat4ub> arrayo1m4ub;
00184 typedef arrayOwn1<mat4i> arrayo1m4i;
00185 typedef arrayOwn1<mat4ui> arrayo1m4ui;
00186 typedef arrayOwn1<mat4f> arrayo1m4f;
00187 #endif
00188
00189 }
00190
00191 #endif // arrayOwn1