source: branches/hpc34/src/STIdxIter.h@ 2870

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

hpc33 merged asap-trunk

File size: 4.2 KB
Line 
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#include <casa/BasicSL/String.h>
10
11#include "Scantable.h"
12
13using namespace std ;
14using namespace casa ;
15
16namespace asap {
17class IndexIterator
18{
19public:
20 IndexIterator( IPosition &shape ) ;
21 Block<uInt> current() { return idx_m ; } ;
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 ;
41 virtual Vector<uInt> getRows( StorageInitPolicy policy=COPY ) = 0 ;
42protected:
43 IndexIterator *iter_m ;
44 uInt nrow_m ;
45 uInt ncol_m ;
46 Block<uInt> storage_m ;
47 Matrix<uInt> arr_m ;
48 IPosition pos_m ;
49 Vector<uInt> current_m ;
50 vector< vector<uInt> > idxlist_m ;
51} ;
52
53class ArrayIndexIteratorNormal : public ArrayIndexIterator
54{
55public:
56 ArrayIndexIteratorNormal( Matrix<uInt> &arr,
57 vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
58 void next() ;
59 Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
60} ;
61
62class ArrayIndexIteratorAcc : public ArrayIndexIterator
63{
64public:
65 ArrayIndexIteratorAcc( Matrix<uInt> &arr,
66 vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
67 void next() ;
68 Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
69private:
70 Int isChanged( Block<uInt> &idx ) ;
71 uInt *updateStorage( Int &icol, uInt *base, uInt &v ) ;
72
73 Block<uInt> prev_m ;
74 Block<uInt> len_m ;
75 Block<Bool> skip_m ;
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() ) ; } ;
92 // !!!you should not use policy=TAKE_OVER since it causes problem!!!
93 Vector<uInt> getRows( StorageInitPolicy policy=COPY ) ;
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,
107 const vector<string> &cols ) ;
108 STIdxIterNormal( const CountedPtr<Scantable> &s,
109 const vector<string> &cols ) ;
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,
121 const vector<string> &cols ) ;
122 STIdxIterAcc( const CountedPtr<Scantable> &s,
123 const vector<string> &cols ) ;
124 ~STIdxIterAcc() ;
125protected:
126 virtual void init( Table &t,
127 const vector<string> &cols ) ;
128} ;
129
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 ;
153 Int srctypeid_m ;
154 Int srcnameid_m ;
155} ;
156
157} // namespace
158#endif /* _ASAP_INDEX_ITERATOR_H_ */
Note: See TracBrowser for help on using the repository browser.