30 #ifndef _D_MULTI_CHANNEL_TYPES_H
31 #define _D_MULTI_CHANNEL_TYPES_H
34 #include "Core/include/DTypes.h"
35 #include "Core/include/DErrors.h"
41 template <
class T=UINT8, UINT N=3>
42 class MultichannelArray;
44 template <
class T, UINT N>
45 class MultichannelArrayItem;
49 template <
class T, UINT N>
56 static UINT channelNumber() {
return N; }
60 for (UINT i=0;i<N;i++)
65 for (UINT i=0;i<N;i++)
76 for (UINT i=0;i<N;i++)
83 for (UINT i=0;i<N;i++)
84 this->value(i) = mc.value(i);
90 for (UINT i=0;i<N;i++)
91 if (this->value(i) != mc.value(i))
95 bool operator ==(
const int &val)
const
97 for (UINT i=0;i<N;i++)
98 if (this->value(i) != val)
104 for (UINT i=0;i<N;i++)
105 if (this->value(i) == mc.value(i))
109 bool operator !=(
const int &val)
const
115 for (UINT i=0;i<N;i++)
116 if (this->value(i) >= mc.value(i))
122 for (UINT i=0;i<N;i++)
123 if (this->value(i) > mc.value(i))
129 for (UINT i=0;i<N;i++)
130 if (this->value(i) <= mc.value(i))
136 for (UINT i=0;i<N;i++)
137 if (this->value(i) < mc.value(i))
144 for (UINT i=0;i<N;i++)
145 newmc.value(i) = ~this->value(i);
152 for (UINT i=0;i<N;i++)
153 newmc.value(i) = !this->value(i);
160 for (UINT i=0;i<N;i++)
161 newmc.value(i) = this->value(i) - mc.value(i);
167 for (UINT i=0;i<N;i++)
168 newmc.value(i) = this->value(i) - val;
174 for (UINT i=0;i<N;i++)
175 newmc.value(i) = this->value(i) - val;
181 for (UINT i=0;i<N;i++)
182 newmc.value(i) = -this->value(i);
188 for (UINT i=0;i<N;i++)
189 newmc.value(i) = this->value(i) + mc.value(i);
195 for (UINT i=0;i<N;i++)
196 newmc.value(i) = this->value(i) + val;
201 for (UINT i=0;i<N;i++)
202 this->value(i) += mc.value(i);
207 for (UINT i=0;i<N;i++)
208 this->value(i) -= mc.value(i);
214 for (UINT i=0;i<N;i++)
215 newmc.value(i) = this->value(i) * mc.value(i);
221 for (UINT i=0;i<N;i++)
222 newmc.value(i) =
static_cast<T
>(this->value(i) * val);
228 for (UINT i=0;i<N;i++)
229 newmc.value(i) = this->value(i) * val;
235 for (UINT i=0;i<N;i++)
236 newmc.value(i) = this->value(i) / mc.value(i);
242 for (UINT i=0;i<N;i++)
243 newmc.value(i) =
static_cast<T
>(this->value(i) / val);
246 MultichannelType operator /(
const size_t &val)
const {
return this->operator/(
double(val)); }
250 for (UINT i=0;i<N;i++)
251 newmc.value(i) = this->value(i) & mc.value(i);
257 for (UINT i=0;i<N;i++)
258 newmc.value(i) = this->value(i) ^ mc.value(i);
264 for (UINT i=0;i<N;i++)
265 newmc.value(i) = this->value(i) | mc.value(i);
270 for (UINT i=0;i<N;i++)
271 this->value(i) |= mc.value(i);
277 for (UINT i=0;i<N;i++)
284 for (UINT i=0;i<N;i++)
285 newmc.value(i) = this->value(i) && mc.value(i);
291 for (UINT i=0;i<N;i++)
292 newmc.value(i) = this->value(i) || mc.value(i);
295 inline T& operator[] (UINT i)
297 return this->value(i);
299 inline const T& operator[] (UINT i)
const
301 return this->value(i);
305 operator double()
const
308 for (UINT i=0;i<N;i++)
313 operator int()
const {
return static_cast<int>(double(*
this)); }
314 operator UINT()
const {
return static_cast<UINT
>(double(*
this)); }
316 operator size_t()
const {
return static_cast<size_t>(double(*
this)); }
318 operator UINT8()
const {
return static_cast<UINT8
>(double(*
this)); }
319 operator UINT16()
const {
return static_cast<UINT16
>(double(*
this)); }
320 operator bool()
const {
325 operator signed char()
const {
326 return static_cast<signed char>(double(*
this));
328 operator char()
const {
return static_cast<char>(double(*
this)); }
329 operator long int()
const {
330 return static_cast<long int>(double(*
this));
332 operator short int()
const {
333 return static_cast<short int>(double(*
this));
336 virtual const T& value(
const UINT &i)
const
340 virtual T& value(
const UINT &i)
346 template <
class T, UINT N>
349 for (UINT i=0;i<N-1;i++)
350 stream <<
double(mc.value(i)) <<
", ";
351 stream << double(mc.value(N-1));
356 template <
class T, UINT N>
366 for (UINT i=0;i<N;i++)
367 _c[i] = &mcArray.arrays[i][
index];
371 for (UINT i=0;i<N;i++)
372 *_c[i] = mc.value(i);
375 virtual const T& value(
const UINT &i)
const
379 virtual T& value(
const UINT &i)
386 template <
class T, UINT N>
399 : size(0),
index(0), allocatedData(
false)
404 : size(rhs.size-rhs.index),
index(0), allocatedData(
false)
406 for (UINT i=0;i<N;i++)
407 arrays[i] = rhs.arrays[i] + rhs.index;
410 : size(rhs.size-rhs.index-newindex),
index(0), allocatedData(
false)
412 for (UINT i=0;i<N;i++)
413 arrays[i] = rhs.arrays[i] + rhs.index + newindex;
416 : size(size),
index(0), allocatedData(
false)
418 for (UINT i=0;i<N;i++)
419 arrays[i] = arrayValsPtr + size*i;
430 for (UINT i=0;i<N;i++)
434 bool isAllocated() {
return allocatedData; }
436 void createArrays(UINT len)
440 for (UINT i=0;i<N;i++)
441 arrays[i] = createAlignedBuffer<T>(len);
443 allocatedData =
true;
449 for (UINT i=0;i<N;i++)
450 deleteAlignedBuffer<T>(arrays[i]);
452 allocatedData =
false;
462 const MCType operator [] (
const int &i)
const
473 bool operator != (
void *ptr)
475 return arrays[0]!=ptr;
477 bool operator == (
void *ptr)
479 return arrays[0]==ptr;
484 ASSERT((ptr==NULL),
"Do not assign pointer to MultichannelArray", *
this);
496 #ifndef USE_64BIT_IDS
518 return arrays[0]+
index - (arr.arrays[0]+arr.index);
526 for (UINT i=0;i<N;i++)
527 arrays[i] = rhs.arrays[i] + rhs.index;
529 size = rhs.size - rhs.index;
530 allocatedData = rhs.allocatedData;
539 return (
char *)arrays;
542 ostream& printSelf(ostream &os=cout);
Definition: DMultichannelTypes.hpp:388
Definition: DMultichannelTypes.hpp:358
Definition: DMultichannelTypes.hpp:51