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