35 virtual inline bool isOK()
const;
36 virtual inline bool isEmpty()
const;
38 virtual T getND(
const int*)
const = 0;
40 virtual void setND(
const int*,T) = 0;
43 {
return getStorage_(); }
47 {
delete s;
return true; }
52 {
return getData_(); }
54 virtual const T* get1D(
const int*)
const;
55 virtual T* get1D(
const int*);
56 virtual int get1DDim()
const;
67 virtual void setAll(T);
68 virtual void getAll(T* ptr)
const;
86 return getStorage()->
arr();
102 virtual void set(int,T) = 0;
103 virtual T
get(int)
const = 0;
104 void setND(
const int* pos,T v) {
set( pos[0], v ); }
106 {
return get(pos[0]); }
116 inline T operator [](
int idx )
const 117 {
return get( idx ); }
130 virtual void set( int, int, T ) = 0;
131 virtual T
get(
int p0,
int p1 )
const = 0;
133 {
set( pos[0], pos[1], v);}
135 {
return get( pos[0], pos[1] ); }
153 virtual void set( int, int, int, T ) = 0;
154 virtual T
get(
int p0,
int p1,
int p2 )
const = 0;
156 {
set( pos[0], pos[1], pos[2], v);}
158 {
return get( pos[0], pos[1], pos[2] ); }
186 template <
class T>
void inline setPos(
const T& idxabl);
187 const int*
getPos()
const {
return position_; }
188 int operator[](
int)
const;
199 #define mArrayNDVSAdapterNrDim 20 215 if ( array_.getData() || array_.getStorage() )
217 pErrMsg(
"Not a good idea to use adapter. " 218 "Use getStorage() instead");
226 pErrMsg(
"Too many dimensions");
239 array_.info().getArrayPos( idx, pos );
240 return array_.getND( pos );
243 const T*
arr()
const {
return array_.getData(); }
254 for (
int idx=
sz_.
getNDim()-1; idx>=0; idx-- )
265 #define mDefArrayNDStdMembers(nd) \ 267 Array##nd##Conv(Array##nd<TT>* arr) \ 269 ~Array##nd##Conv() { delete arr_; } \ 271 const Array##nd##Info& info() const { return arr_->info(); } \ 275 Array##nd<TT>* arr_; \ 279 #define mDefArrayNDConverter(nd) \ 280 template <class T, class TT> \ 281 class Array##nd##Conv : public Array##nd<T> \ 282 { mDefArrayNDStdMembers(nd); 286 template <
class T,
class TT>
290 T
get(
int p0 )
const 291 {
return (T)arr_->get( p0 ); }
292 void set(
int p0, T v )
293 { arr_->set( p0, (TT)v ); }
298 template <
class T,
class TT>
301 T
get(
int p0,
int p1 )
const 302 {
return (T)arr_->get( p0, p1 ); }
303 void set(
int p0,
int p1, T v )
304 { arr_->set( p0, p1, (TT)v ); }
308 template <
class T,
class TT>
312 T
get(
int p0,
int p1,
int p2 )
const 313 {
return (T)arr_->get( p0, p1, p2 ); }
314 void set(
int p0,
int p1,
int p2, T v )
315 { arr_->set( p0, p1, p2, (TT)v ); }
322 template <
class T>
inline 325 return getStorage() ? getStorage()->isOK() :
true;
329 template <
class T>
inline 332 return !isOK() || info().getTotalSz() == 0;
336 template <
class T>
inline 339 const T* ptr = getData();
340 if ( !ptr )
return 0;
342 int ndim = info().getNDim();
345 OD::memCopy(pos,i, (
int)
sizeof(
int)*(ndim-1));
349 return &ptr[info().getOffset( pos )];
353 template <
class T>
inline 355 {
return info().getNDim()-1; }
358 template <
class T>
inline 361 return !isSettable() ? 0
362 :
const_cast<T*
>(((
const ArrayND*)
this)->getData_());
366 template <
class T>
inline 369 return !isSettable() ? 0 :
374 template <
class T>
inline 377 return !isSettable() ? 0 :
const_cast<T*
>(((
const ArrayND*)
this)->get1D(i));
381 template <
class T>
inline 404 setND( iterator.
getPos(), val );
405 }
while ( iterator.
next() );
419 , totalnr_( arr.info().getTotalSz() )
426 , totalnr_( arr.info().getTotalSz() )
427 , vs_( vs.arr() ? 0 : &vs )
433 if ( !arr_.info().getArrayPos( start, pos ) )
437 iterator.
setPos( (
int*) pos );
441 for (
od_int64 idx=start; idx<=stop; idx++ )
444 arr_.getND( iterator.getPos() ) );
448 if ( !iterator.next() )
454 T* res = ptr_ + start;
455 for (
od_int64 idx=start; idx<=stop; idx++, res++ )
457 *res = arr_.getND( iterator.getPos() );
461 if ( !iterator.next() )
481 template <
class T>
inline 485 { getAll( vs.
arr() );
return; }
487 const od_int64 totalsz = info().getTotalSz();
502 template <
class T>
inline 505 const od_int64 totalsz = info().getTotalSz();
509 const T* tdata = getData();
511 OD::memCopy( ptr, tdata, totalsz *
sizeof(T) );
Array1D ( Subclass of ArrayND ) is a one dimensional array.
Definition: arraynd.h:97
#define mExpClass(module)
Definition: commondefs.h:157
virtual int getNDim() const =0
void getValues(ValueSeries< T > &, int64_t nrvals) const
Definition: valseries.h:126
virtual bool canSetStorage() const
Definition: arraynd.h:45
T value(int64_t i) const
Definition: arraynd.h:109
virtual bool setStorage(ValueSeries< T > *s)
Definition: arraynd.h:46
const T * arr() const
Definition: arraynd.h:243
virtual T ** get2DData()
Definition: arraynd.h:137
Sets large amounts of values to a constant using multiple threads.
Definition: odmemory.h:40
Contains the information about the size of Array3D, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:116
const ValueSeries< T > * getStorage() const
Definition: arraynd.h:42
#define od_int64
Definition: plftypes.h:34
ValueSeries< T > * clone() const
Definition: arraynd.h:233
virtual const T * get1D(const int *) const
Definition: arraynd.h:337
Contains the information about the size of ArrayND, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:21
Contains the information about the size of Array1D, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:69
int * position_
Definition: arraynd.h:194
T value(int64_t idx) const
Definition: arraynd.h:236
virtual bool getArrayPos(uint64_t, int *) const
virtual bool isSettable() const
Definition: arraynd.h:39
Definition: arraynd.h:309
ArrayNDValseriesAdapter(const ArrayND< T > &a)
Definition: arraynd.h:212
virtual const T ** get2DData() const
Definition: arraynd.h:138
const ArrayNDInfo & sz_
Definition: arraynd.h:195
virtual int get1DDim() const
Definition: arraynd.h:354
virtual bool isEmpty() const
Definition: arraynd.h:330
Generalization of a task that can be run in parallel.
Definition: paralleltask.h:64
const ArrayND< T > & array_
Definition: arraynd.h:248
const T * getData() const
Definition: arraynd.h:51
virtual bool canSetInfo() const
Definition: arraynd.h:60
Definition: arraynd.h:287
T * arr()
Definition: arraynd.h:244
Array2D ( Subclass of ArrayND ) is a two dimensional array.
Definition: arraynd.h:127
bool writable() const
Definition: arraynd.h:110
virtual void setAll(T t)
Definition: arraynd.h:112
void setPos(const T &idxabl)
Definition: arraynd.h:252
bool execute()
Definition: paralleltask.h:69
Interface to a series of values.
Definition: odmemory.h:15
bool setGlobalPos(int64_t)
Definition: arraynd.h:260
virtual const ValueSeries< T > * getStorage_() const
Definition: arraynd.h:81
virtual const T *** get3DData() const
Definition: arraynd.h:161
T getND(const int *pos) const
Definition: arraynd.h:157
virtual T *** get3DData()
Definition: arraynd.h:160
Contains the information about the size of Array2D, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:93
void setND(const int *pos, T v)
Definition: arraynd.h:104
#define mAllocVarLenArr(type, varnm, __size)
Definition: varlenarray.h:52
virtual bool canChangeNrDims() const
Definition: arraynd.h:62
virtual void setAll(T)
Definition: arraynd.h:382
virtual void setAll(T)
Definition: valseries.h:43
An ArrayND is an array with a given number of dimensions and a size.
Definition: arraynd.h:29
Iterates through all samples in an ArrayND.
Definition: arraynd.h:175
void setND(const int *pos, T v)
Definition: arraynd.h:132
bool isEmpty(const char *)
virtual bool setInfo(const ArrayNDInfo &)
Definition: arraynd.h:64
const int * getPos() const
Definition: arraynd.h:187
#define mAllocLargeVarLenArr(type, varnm, __size)
Definition: varlenarray.h:29
virtual const T * getData_() const
Definition: arraynd.h:83
Definition: arraynd.h:299
ValueSeries Copier.
Definition: odmemory.h:87
virtual bool canSetAll() const
Definition: valseries.h:42
T getND(const int *pos) const
Definition: arraynd.h:105
void setND(const int *pos, T v)
Definition: arraynd.h:155
virtual bool isOK() const
Definition: arraynd.h:323
void setValue(int64_t i, T t)
Definition: arraynd.h:111
#define mClass(module)
Definition: commondefs.h:161
#define pErrMsg(msg)
Usual access point for programmer error messages.
Definition: errmsg.h:34
#define mDefArrayNDStdMembers(nd)
Definition: arraynd.h:265
T getND(const int *pos) const
Definition: arraynd.h:134
virtual void getAll(T *ptr) const
Definition: arraynd.h:503
Adapter that makes any ArrayND to a (slow) value series.
Definition: arraynd.h:209
#define mArrayNDVSAdapterNrDim
Definition: arraynd.h:199
Array3D ( Subclass of ArrayND ) is a three dimensional array.
Definition: arraynd.h:149
virtual ~ArrayND()
Definition: arraynd.h:33
virtual T * arr()
Definition: valseries.h:48
bool isOK() const
Definition: arraynd.h:222