source: trunk/src/STIdxIter.h@ 2673

Last change on this file since 2673 was 2580, checked in by ShinnosukeKawakami, 12 years ago

hpc33 merged asap-trunk

File size: 4.2 KB
RevLine 
[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>
[2533]8#include <casa/Arrays/IPosition.h>
[2537]9#include <casa/BasicSL/String.h>
[2519]10
11#include "Scantable.h"
12
13using namespace std ;
14using namespace casa ;
15
16namespace asap {
17class IndexIterator
18{
19public:
[2533]20 IndexIterator( IPosition &shape ) ;
21 Block<uInt> current() { return idx_m ; } ;
[2519]22 Bool pastEnd() ;
23 void next() ;
24private:
25 uInt nfield_m ;
26 Block<uInt> prod_m ;
27 Block<uInt> idx_m ;
28 uInt niter_m ;
29 uInt maxiter_m ;
30} ;
31
32class ArrayIndexIterator
33{
34public:
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]42protected:
43 IndexIterator *iter_m ;
44 uInt nrow_m ;
45 uInt ncol_m ;
[2533]46 Block<uInt> storage_m ;
[2519]47 Matrix<uInt> arr_m ;
[2533]48 IPosition pos_m ;
49 Vector<uInt> current_m ;
50 vector< vector<uInt> > idxlist_m ;
[2519]51} ;
52
53class ArrayIndexIteratorNormal : public ArrayIndexIterator
54{
55public:
56 ArrayIndexIteratorNormal( Matrix<uInt> &arr,
57 vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
58 void next() ;
[2524]59 Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
[2519]60} ;
61
62class ArrayIndexIteratorAcc : public ArrayIndexIterator
63{
64public:
65 ArrayIndexIteratorAcc( Matrix<uInt> &arr,
66 vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
67 void next() ;
[2524]68 Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
[2519]69private:
[2536]70 Int isChanged( Block<uInt> &idx ) ;
[2519]71 uInt *updateStorage( Int &icol, uInt *base, uInt &v ) ;
72
[2536]73 Block<uInt> prev_m ;
[2519]74 Block<uInt> len_m ;
[2536]75 Block<Bool> skip_m ;
[2519]76} ;
77
78class STIdxIter
79{
80public:
81 STIdxIter() ;
82 STIdxIter( const string &name,
83 const vector<string> &cols ) ;
84 STIdxIter( const CountedPtr<Scantable> &s,
85 const vector<string> &cols ) ;
86 virtual ~STIdxIter() ;
87 vector<uInt> currentSTL() { return tovector( iter_m->current() ) ; } ;
88 Vector<uInt> current() { return iter_m->current() ; } ;
89 Bool pastEnd() { return iter_m->pastEnd() ; } ;
90 void next() { iter_m->next() ; } ;
91 vector<uInt> getRowsSTL() { return tovector( iter_m->getRows() ) ; } ;
[2536]92 // !!!you should not use policy=TAKE_OVER since it causes problem!!!
[2533]93 Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
[2519]94protected:
95 ArrayIndexIterator *iter_m ;
96 virtual void init( Table &t,
97 const vector<string> &cols ) = 0 ;
98private:
99 vector<uInt> tovector( Vector<uInt> v ) ;
100} ;
101
102class STIdxIterNormal : public STIdxIter
103{
104public:
105 STIdxIterNormal() ;
106 STIdxIterNormal( const string &name,
[2536]107 const vector<string> &cols ) ;
[2519]108 STIdxIterNormal( const CountedPtr<Scantable> &s,
[2536]109 const vector<string> &cols ) ;
[2519]110 ~STIdxIterNormal() ;
111protected:
112 void init( Table &t,
113 const vector<string> &cols ) ;
114} ;
115
116class STIdxIterAcc : public STIdxIter
117{
118public:
119 STIdxIterAcc() ;
120 STIdxIterAcc( const string &name,
[2536]121 const vector<string> &cols ) ;
[2519]122 STIdxIterAcc( const CountedPtr<Scantable> &s,
[2536]123 const vector<string> &cols ) ;
[2519]124 ~STIdxIterAcc() ;
125protected:
[2536]126 virtual void init( Table &t,
127 const vector<string> &cols ) ;
[2519]128} ;
129
[2537]130class STIdxIterExAcc : public STIdxIter
131{
132public:
133 STIdxIterExAcc() ;
134 STIdxIterExAcc( const string &name,
135 const vector<string> &cols ) ;
136 STIdxIterExAcc( const CountedPtr<Scantable> &s,
137 const vector<string> &cols ) ;
138 ~STIdxIterExAcc() ;
139 Int getSrcType() ;
140 String getSrcName() ;
141protected:
142 virtual void init( Table &t,
143 const vector<string> &cols ) ;
144private:
145 void processIntCol( Vector<Int> &in,
146 Vector<uInt> &out,
147 Block<Int> &val ) ;
148 void processStrCol( Vector<String> &in,
149 Vector<uInt> &out,
150 Block<String> &val ) ;
151 Block<Int> srctype_m ;
152 Block<String> srcname_m ;
[2547]153 Int srctypeid_m ;
154 Int srcnameid_m ;
[2537]155} ;
[2536]156
[2519]157} // namespace
158#endif /* _ASAP_INDEX_ITERATOR_H_ */
Note: See TracBrowser for help on using the repository browser.