PolyVox
0.3.0-dev
Open source voxel management library
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
PolyVoxCore
include
PolyVoxCore
Array.h
Go to the documentation of this file.
1
/*******************************************************************************
2
Copyright (c) 2005-2009 David Williams
3
4
This software is provided 'as-is', without any express or implied
5
warranty. In no event will the authors be held liable for any damages
6
arising from the use of this software.
7
8
Permission is granted to anyone to use this software for any purpose,
9
including commercial applications, and to alter it and redistribute it
10
freely, subject to the following restrictions:
11
12
1. The origin of this software must not be misrepresented; you must not
13
claim that you wrote the original software. If you use this software
14
in a product, an acknowledgment in the product documentation would be
15
appreciated but is not required.
16
17
2. Altered source versions must be plainly marked as such, and must not be
18
misrepresented as being the original software.
19
20
3. This notice may not be removed or altered from any source
21
distribution.
22
*******************************************************************************/
23
24
#ifndef __PolyVox_Array_H__
25
#define __PolyVox_Array_H__
26
27
#include "
Impl/SubArray.h
"
28
29
#include "
PolyVoxCore/ArraySizes.h
"
//Not strictly required, but convienient
30
31
namespace
PolyVox
32
{
75
template
<u
int
32_t noOfDims,
typename
ElementType>
76
class
Array
77
{
78
public
:
80
Array<noOfDims, ElementType>
();
82
Array<noOfDims, ElementType>
(
const
uint32_t
(&pDimensions)[noOfDims]);
84
~
Array<noOfDims, ElementType>
();
85
87
SubArray
<noOfDims-1, ElementType>
operator[]
(
uint32_t
uIndex);
89
const
SubArray
<noOfDims-1, ElementType>
operator[]
(
uint32_t
uIndex)
const
;
90
92
uint32_t
getNoOfElements
(
void
)
const
;
94
ElementType*
getRawData
(
void
)
const
;
95
97
void
resize
(
const
uint32_t
(&pDimensions)[noOfDims]);
99
void
swap
(
Array<noOfDims, ElementType>
& rhs);
101
uint32_t
getDimension
(
uint32_t
uDimension);
102
103
private
:
104
Array<noOfDims, ElementType>
(
const
Array<noOfDims, ElementType>
& rhs);
105
106
Array<noOfDims, ElementType>
& operator=(
const
Array<noOfDims, ElementType>
& rhs);
107
108
void
deallocate(
void
);
109
110
uint32_t
* m_pDimensions;
111
uint32_t
* m_pOffsets;
112
uint32_t
m_uNoOfElements;
113
ElementType * m_pElements;
114
};
115
116
template
<
typename
ElementType>
117
class
Array
<1, ElementType>
118
{
119
public
:
120
Array<1, ElementType>
();
121
122
Array<1, ElementType>
(
const
uint32_t
(&pDimensions)[1]);
123
124
~
Array<1, ElementType>
();
125
126
ElementType&
operator[]
(
uint32_t
uIndex);
127
128
const
ElementType&
operator[]
(
uint32_t
uIndex)
const
;
129
130
uint32_t
getNoOfElements
(
void
)
const
;
131
132
ElementType*
getRawData
(
void
)
const
;
133
134
void
resize
(
const
uint32_t
(&pDimensions)[1]);
135
136
void
swap
(
Array<1, ElementType>
& rhs);
137
138
private
:
139
Array<1, ElementType>
(
const
Array<1, ElementType>
& rhs);
140
141
Array<1, ElementType>
& operator=(
const
Array<1, ElementType>
& rhs);
142
143
void
deallocate(
void
);
144
145
uint32_t
* m_pDimensions;
146
ElementType * m_pElements;
147
};
148
149
template
<
typename
ElementType>
150
class
Array
<0, ElementType>
151
{
152
//Zero dimensional array is meaningless.
153
};
154
155
//Some handy typedefs
157
typedef
Array<1,float>
Array1DFloat
;
159
typedef
Array<1,double>
Array1DDouble
;
161
typedef
Array<1,int8_t>
Array1DInt8
;
163
typedef
Array<1,uint8_t>
Array1DUint8
;
165
typedef
Array<1,int16_t>
Array1DInt16
;
167
typedef
Array<1,uint16_t>
Array1DUint16
;
169
typedef
Array<1,int32_t>
Array1DInt32
;
171
typedef
Array<1,uint32_t>
Array1DUint32
;
172
174
typedef
Array<2,float>
Array2DFloat
;
176
typedef
Array<2,double>
Array2DDouble
;
178
typedef
Array<2,int8_t>
Array2DInt8
;
180
typedef
Array<2,uint8_t>
Array2DUint8
;
182
typedef
Array<2,int16_t>
Array2DInt16
;
184
typedef
Array<2,uint16_t>
Array2DUint16
;
186
typedef
Array<2,int32_t>
Array2DInt32
;
188
typedef
Array<2,uint32_t>
Array2DUint32
;
189
191
typedef
Array<3,float>
Array3DFloat
;
193
typedef
Array<3,double>
Array3DDouble
;
195
typedef
Array<3,int8_t>
Array3DInt8
;
197
typedef
Array<3,uint8_t>
Array3DUint8
;
199
typedef
Array<3,int16_t>
Array3DInt16
;
201
typedef
Array<3,uint16_t>
Array3DUint16
;
203
typedef
Array<3,int32_t>
Array3DInt32
;
205
typedef
Array<3,uint32_t>
Array3DUint32
;
206
}
//namespace PolyVox
207
208
#include "
PolyVoxCore/Array.inl
"
209
210
#endif
Generated by
1.8.2