00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __PolyVox_Array_H__
00025 #define __PolyVox_Array_H__
00026
00027 #include "PolyVoxImpl/SubArray.h"
00028
00029 #include "PolyVoxCore/ArraySizes.h"
00030
00031 namespace PolyVox
00032 {
00075 template <uint32_t noOfDims, typename ElementType>
00076 class Array
00077 {
00078 public:
00080 Array<noOfDims, ElementType>();
00082 Array<noOfDims, ElementType>(const uint32_t (&pDimensions)[noOfDims]);
00084 ~Array<noOfDims, ElementType>();
00085
00087 SubArray<noOfDims-1, ElementType> operator[](uint32_t uIndex);
00089 const SubArray<noOfDims-1, ElementType> operator[](uint32_t uIndex) const;
00090
00092 uint32_t getNoOfElements(void) const;
00094 ElementType* getRawData(void) const;
00095
00097 void resize(const uint32_t (&pDimensions)[noOfDims]);
00099 void swap(Array<noOfDims, ElementType>& rhs);
00101 uint32_t getDimension(uint32_t uDimension);
00102
00103 private:
00104 Array<noOfDims, ElementType>(const Array<noOfDims, ElementType>& rhs);
00105
00106 Array<noOfDims, ElementType>& operator=(const Array<noOfDims, ElementType>& rhs);
00107
00108 void deallocate(void);
00109
00110 uint32_t * m_pDimensions;
00111 uint32_t * m_pOffsets;
00112 uint32_t m_uNoOfElements;
00113 ElementType * m_pElements;
00114 };
00115
00116 template <typename ElementType>
00117 class Array<1, ElementType>
00118 {
00119 public:
00120 Array<1, ElementType>();
00121
00122 Array<1, ElementType>(const uint32_t (&pDimensions)[1]);
00123
00124 ~Array<1, ElementType>();
00125
00126 ElementType& operator[] (uint32_t uIndex);
00127
00128 const ElementType& operator[] (uint32_t uIndex) const;
00129
00130 uint32_t getNoOfElements(void) const;
00131
00132 ElementType* getRawData(void) const;
00133
00134 void resize(const uint32_t (&pDimensions)[1]);
00135
00136 void swap(Array<1, ElementType>& rhs);
00137
00138 private:
00139 Array<1, ElementType>(const Array<1, ElementType>& rhs);
00140
00141 Array<1, ElementType>& operator=(const Array<1, ElementType>& rhs);
00142
00143 void deallocate(void);
00144
00145 uint32_t * m_pDimensions;
00146 ElementType * m_pElements;
00147 };
00148
00149 template <typename ElementType>
00150 class Array<0, ElementType>
00151 {
00152
00153 };
00154
00155
00157 typedef Array<1,float> Array1DFloat;
00159 typedef Array<1,double> Array1DDouble;
00161 typedef Array<1,int8_t> Array1DInt8;
00163 typedef Array<1,uint8_t> Array1DUint8;
00165 typedef Array<1,int16_t> Array1DInt16;
00167 typedef Array<1,uint16_t> Array1DUint16;
00169 typedef Array<1,int32_t> Array1DInt32;
00171 typedef Array<1,uint32_t> Array1DUint32;
00172
00174 typedef Array<2,float> Array2DFloat;
00176 typedef Array<2,double> Array2DDouble;
00178 typedef Array<2,int8_t> Array2DInt8;
00180 typedef Array<2,uint8_t> Array2DUint8;
00182 typedef Array<2,int16_t> Array2DInt16;
00184 typedef Array<2,uint16_t> Array2DUint16;
00186 typedef Array<2,int32_t> Array2DInt32;
00188 typedef Array<2,uint32_t> Array2DUint32;
00189
00191 typedef Array<3,float> Array3DFloat;
00193 typedef Array<3,double> Array3DDouble;
00195 typedef Array<3,int8_t> Array3DInt8;
00197 typedef Array<3,uint8_t> Array3DUint8;
00199 typedef Array<3,int16_t> Array3DInt16;
00201 typedef Array<3,uint16_t> Array3DUint16;
00203 typedef Array<3,int32_t> Array3DInt32;
00205 typedef Array<3,uint32_t> Array3DUint32;
00206 }
00207
00208 #include "PolyVoxCore/Array.inl"
00209
00210 #endif