[2519] | 1 | #ifndef _ASAP_INDEX_ITERATOR_H_
|
---|
| 2 | #define _ASAP_INDEX_ITERATOR_H_
|
---|
| 3 |
|
---|
| 4 | #include <vector>
|
---|
| 5 | #include <casa/Containers/Block.h>
|
---|
| 6 | #include <casa/Arrays/Vector.h>
|
---|
| 7 | #include <casa/Arrays/Matrix.h>
|
---|
| 8 |
|
---|
| 9 | #include "Scantable.h"
|
---|
| 10 |
|
---|
| 11 | using namespace std ;
|
---|
| 12 | using namespace casa ;
|
---|
| 13 |
|
---|
| 14 | namespace asap {
|
---|
| 15 | class IndexIterator
|
---|
| 16 | {
|
---|
| 17 | public:
|
---|
| 18 | IndexIterator( vector< vector<uInt> > &idlist ) ;
|
---|
| 19 | Vector<uInt> current() ;
|
---|
| 20 | Bool pastEnd() ;
|
---|
| 21 | void next() ;
|
---|
| 22 | private:
|
---|
| 23 | vector< vector<uInt> > idxlist_m ;
|
---|
| 24 | uInt nfield_m ;
|
---|
| 25 | Block<uInt> prod_m ;
|
---|
| 26 | Block<uInt> idx_m ;
|
---|
| 27 | uInt niter_m ;
|
---|
| 28 | uInt maxiter_m ;
|
---|
| 29 | Vector<uInt> current_m ;
|
---|
| 30 | } ;
|
---|
| 31 |
|
---|
| 32 | class ArrayIndexIterator
|
---|
| 33 | {
|
---|
| 34 | public:
|
---|
| 35 | ArrayIndexIterator( Matrix<uInt> &arr,
|
---|
| 36 | vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
|
---|
| 37 | virtual ~ArrayIndexIterator() ;
|
---|
| 38 | Vector<uInt> current() ;
|
---|
| 39 | Bool pastEnd() ;
|
---|
| 40 | virtual void next() = 0 ;
|
---|
[2524] | 41 | virtual Vector<uInt> getRows( StorageInitPolicy policy=COPY ) = 0 ;
|
---|
[2519] | 42 | protected:
|
---|
| 43 | IndexIterator *iter_m ;
|
---|
| 44 | uInt nrow_m ;
|
---|
| 45 | uInt ncol_m ;
|
---|
| 46 | //Vector<uInt> storage_m ;
|
---|
| 47 | Matrix<uInt> arr_m ;
|
---|
| 48 | //IPosition pos_m ;
|
---|
| 49 | } ;
|
---|
| 50 |
|
---|
| 51 | class ArrayIndexIteratorNormal : public ArrayIndexIterator
|
---|
| 52 | {
|
---|
| 53 | public:
|
---|
| 54 | ArrayIndexIteratorNormal( Matrix<uInt> &arr,
|
---|
| 55 | vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
|
---|
| 56 | void next() ;
|
---|
[2524] | 57 | Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
|
---|
[2519] | 58 | private:
|
---|
| 59 | Block<uInt> storage_m ;
|
---|
| 60 | IPosition pos_m ;
|
---|
| 61 | } ;
|
---|
| 62 |
|
---|
| 63 | class ArrayIndexIteratorAcc : public ArrayIndexIterator
|
---|
| 64 | {
|
---|
| 65 | public:
|
---|
| 66 | ArrayIndexIteratorAcc( Matrix<uInt> &arr,
|
---|
| 67 | vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
|
---|
| 68 | void next() ;
|
---|
[2524] | 69 | Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
|
---|
[2519] | 70 | private:
|
---|
| 71 | Int isChanged( Vector<uInt> &idx ) ;
|
---|
| 72 | uInt *updateStorage( Int &icol, uInt *base, uInt &v ) ;
|
---|
| 73 |
|
---|
| 74 | Vector<uInt> prev_m ;
|
---|
| 75 | Block<uInt> storage_m ;
|
---|
| 76 | IPosition pos_m ;
|
---|
| 77 | Block<uInt> len_m ;
|
---|
| 78 | } ;
|
---|
| 79 |
|
---|
| 80 | class STIdxIter
|
---|
| 81 | {
|
---|
| 82 | public:
|
---|
| 83 | STIdxIter() ;
|
---|
| 84 | STIdxIter( const string &name,
|
---|
| 85 | const vector<string> &cols ) ;
|
---|
| 86 | STIdxIter( const CountedPtr<Scantable> &s,
|
---|
| 87 | const vector<string> &cols ) ;
|
---|
| 88 | virtual ~STIdxIter() ;
|
---|
| 89 | vector<uInt> currentSTL() { return tovector( iter_m->current() ) ; } ;
|
---|
| 90 | Vector<uInt> current() { return iter_m->current() ; } ;
|
---|
| 91 | Bool pastEnd() { return iter_m->pastEnd() ; } ;
|
---|
| 92 | void next() { iter_m->next() ; } ;
|
---|
| 93 | vector<uInt> getRowsSTL() { return tovector( iter_m->getRows() ) ; } ;
|
---|
[2524] | 94 | Vector<uInt> getRows( StorageInitPolicy policy=COPY ) { return iter_m->getRows( policy ) ; } ;
|
---|
[2519] | 95 | protected:
|
---|
| 96 | ArrayIndexIterator *iter_m ;
|
---|
| 97 | virtual void init( Table &t,
|
---|
| 98 | const vector<string> &cols ) = 0 ;
|
---|
| 99 | private:
|
---|
| 100 | vector<uInt> tovector( Vector<uInt> v ) ;
|
---|
| 101 | } ;
|
---|
| 102 |
|
---|
| 103 | class STIdxIterNormal : public STIdxIter
|
---|
| 104 | {
|
---|
| 105 | public:
|
---|
| 106 | STIdxIterNormal() ;
|
---|
| 107 | STIdxIterNormal( const string &name,
|
---|
| 108 | const vector<string> &cols ) ;
|
---|
| 109 | STIdxIterNormal( const CountedPtr<Scantable> &s,
|
---|
| 110 | const vector<string> &cols ) ;
|
---|
| 111 | ~STIdxIterNormal() ;
|
---|
| 112 | protected:
|
---|
| 113 | void init( Table &t,
|
---|
| 114 | const vector<string> &cols ) ;
|
---|
| 115 | } ;
|
---|
| 116 |
|
---|
| 117 | class STIdxIterAcc : public STIdxIter
|
---|
| 118 | {
|
---|
| 119 | public:
|
---|
| 120 | STIdxIterAcc() ;
|
---|
| 121 | STIdxIterAcc( const string &name,
|
---|
| 122 | const vector<string> &cols ) ;
|
---|
| 123 | STIdxIterAcc( const CountedPtr<Scantable> &s,
|
---|
| 124 | const vector<string> &cols ) ;
|
---|
| 125 | ~STIdxIterAcc() ;
|
---|
| 126 | protected:
|
---|
| 127 | void init( Table &t,
|
---|
| 128 | const vector<string> &cols ) ;
|
---|
| 129 | } ;
|
---|
| 130 |
|
---|
| 131 | } // namespace
|
---|
| 132 | #endif /* _ASAP_INDEX_ITERATOR_H_ */
|
---|