arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

arrayWrap1.h

Go to the documentation of this file.
00001 /*
00002  * $Id: arrayWrap1.h,v 1.4 2003/08/08 16:22:08 jmk Exp $
00003  */
00004 ///////////////////////////////////////////////////////////////////////////
00005 //              _____________  ______________________    __   __  _____
00006 //             /  ________  |  |   ___   ________   /   |  \ /  \   |
00007 //            |  |       |  |_ |  |_ |  |       /  /    \__  |      |
00008 //            |  |  ___  |  || |  || |  |      /  /        | |      |
00009 //            |  | |   \ |  || |  || |  |     /  /      \__/ \__/ __|__
00010 //            |  | |_@  ||  || |  || |  |    /  /          Institute
00011 //            |  |___/  ||  ||_|  || |  |   /  /_____________________
00012 //             \_______/  \______/ | |__|  /___________________________
00013 //                        |  |__|  |
00014 //                         \______/
00015 //                    University of Utah       
00016 //                           2002
00017 ///////////////////////////////////////////////////////////////////////////
00018 ////////////////////////////////////////////////////////////////////////
00019 // 9/8/02       Aaron Lefohn    Scientific Computing and Imaging Institute
00020 //                      Joe M. Kniss    School of Computing
00021 //                                                      University of Utah
00022 //
00023 //  Array1 - An Array WRAPPER class.
00024 //         - This is a lightweight class that does NOT own its data.
00025 //         - Copies of "arrayWrap1" objects are shallow.
00026 //         - The constructor does NOT allocate any memory.
00027 //                 - The destructor does NOT free the memory.
00028 //                 - The (i) and [i] operators are identical for the 1D case.
00029 //                   Both exist here for compatibility with higher-dimensional arrays.
00030 ////////////////////////////////////////////////////////////////////////
00031 
00032 #ifndef ARRAY_WRAP_1_h
00033 #define ARRAY_WRAP_1_h
00034 
00035 #include <../arrayGutz/arrayBase.h>
00036 #include <assert.h>
00037 #include "../mathGutz/mm.h"
00038 
00039 #ifdef USING_MATHGUTZ
00040         #include <mathGutz.h>
00041 #endif
00042 
00043 namespace gutz
00044 {
00045 
00046 // Foward Decl
00047 template <class T> class arrayWrap2;
00048 
00049 //////////////////////////////
00050 // arrayWrap1
00051 //////////////////////////////
00052 template <class T>
00053 class arrayWrap1 : public arrayBase<T>
00054 {
00055 public:
00056         friend class arrayWrap2<T>; // This is a friend so that it can access the 'setData' function.
00057 
00058         // Constructors - Shallow wrap around data
00059         // WARNING: No size checking is done here so be sure to get allocation correct!!
00060         arrayWrap1();
00061         arrayWrap1( int s, T* v);
00062         arrayWrap1( const arrayWrap1<T>& a );
00063         arrayWrap1<T>& operator=( const arrayWrap1<T>& a );
00064 
00065     ~arrayWrap1();
00066 
00067         // Accessors - The [] and () operators are identical here, but here for consistency with
00068         //                         the higher-dimensional arrays.
00069     inline T&           operator[] (int i)                      { assert(i < mSize); return mData[i]; }
00070     inline const T      operator[] (int i) const        { assert(i < mSize); return mData[i]; }
00071     inline T&           operator() (int i)                      { assert(i < mSize); return mData[i]; }
00072     inline  const T operator() (int i) const    { assert(i < mSize); return mData[i]; }
00073 
00074 protected:
00075 
00076 private:
00077         inline void     setData(T* d) {mData = d;}
00078 };
00079 
00080 ////////////////////////////////////
00081 // Implementation
00082 ////////////////////////////////////
00083 
00084 // Constructors - All are shallow!!
00085 template <class T>
00086 arrayWrap1<T>::arrayWrap1()
00087 :arrayBase<T>()
00088 {
00089 }
00090 
00091 template <class T>
00092 arrayWrap1<T>::arrayWrap1( int size, T* data )
00093 :arrayBase<T>(size,data)
00094 {
00095 }
00096 
00097 // Copy Ctor
00098 template <class T>
00099 arrayWrap1<T>::arrayWrap1<T>( const arrayWrap1<T>& a ) : arrayBase<T>(a)
00100 {}
00101 
00102 // Assignment Op
00103 template <class T>
00104 arrayWrap1<T>& arrayWrap1<T>::operator=(const arrayWrap1<T>& a)
00105 {
00106         if( this != &a ) {
00107                 arrayBase<T>::operator=(a);// Call base class assign. op
00108         }
00109         return *this;
00110 }
00111 
00112 // Destructor
00113 template <class T>
00114 arrayWrap1<T>::~arrayWrap1()
00115 {}
00116 
00117 ////////////////////////////////////
00118 // Typedefs
00119 ////////////////////////////////////
00120 
00121 typedef arrayWrap1<char>        arrayw1c;
00122 typedef arrayWrap1<uchar>       arrayw1uc;
00123 typedef arrayWrap1<char>        arrayw1b;
00124 typedef arrayWrap1<uchar>       arrayw1ub;
00125 typedef arrayWrap1<short>       arrayw1s;
00126 typedef arrayWrap1<ushort>      arrayw1us;
00127 typedef arrayWrap1<int>         arrayw1i;
00128 typedef arrayWrap1<uint>        arrayw1ui;
00129 typedef arrayWrap1<long>        arrayw1l;
00130 typedef arrayWrap1<ulong>       arrayw1ul;
00131 typedef arrayWrap1<llong>       arrayw1ll;
00132 typedef arrayWrap1<ullong>      arrayw1ull;
00133 typedef arrayWrap1<float>       arrayw1f;
00134 typedef arrayWrap1<double>      arrayw1d;
00135 
00136 #ifdef USING_MATHGUTZ
00137         typedef arrayWrap1<vec2ub> arrayw1v2ub;
00138         typedef arrayWrap1<vec2i>  arrayw1v2i;
00139         typedef arrayWrap1<vec2ui> arrayw1v2ui;
00140         typedef arrayWrap1<vec2f>  arrayw1v2f;
00141 
00142         typedef arrayWrap1<vec3ub> arrayw1v3ub;
00143         typedef arrayWrap1<vec3i>  arrayw1v3i;
00144         typedef arrayWrap1<vec3ui> arrayw1v3ui;
00145         typedef arrayWrap1<vec3f>  arrayw1v3f;
00146 
00147         typedef arrayWrap1<vec4ub> arrayw1v4ub;
00148         typedef arrayWrap1<vec4i>  arrayw1v4i;
00149         typedef arrayWrap1<vec4ui> arrayw1v4ui;
00150         typedef arrayWrap1<vec4f>  arrayw1v4f;
00151 
00152         typedef arrayWrap1<mat2ub> arrayw1m2ub;
00153         typedef arrayWrap1<mat2i>  arrayw1m2i;
00154         typedef arrayWrap1<mat2ui> arrayw1m2ui;
00155         typedef arrayWrap1<mat2f>  arrayw1m2f;
00156 
00157         typedef arrayWrap1<mat3ub> arrayw1m3ub;
00158         typedef arrayWrap1<mat3i>  arrayw1m3i;
00159         typedef arrayWrap1<mat3ui> arrayw1m3ui;
00160         typedef arrayWrap1<mat3f>  arrayw1m3f;
00161 
00162         typedef arrayWrap1<mat4ub> arrayw1m4ub;
00163         typedef arrayWrap1<mat4i>  arrayw1m4i;
00164         typedef arrayWrap1<mat4ui> arrayw1m4ui;
00165         typedef arrayWrap1<mat4f>  arrayw1m4f;
00166 #endif
00167 
00168 } // End of namespace gutz
00169 
00170 #endif // arrayWrap1_h
00171 

Send questions, comments, and bug reports to:
jmk