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 <casa/Utilities/Sort.h>
|
---|
12 |
|
---|
13 | #include "Scantable.h"
|
---|
14 |
|
---|
15 | using namespace std ;
|
---|
16 | using namespace casacore;
|
---|
17 |
|
---|
18 | //namespace {
|
---|
19 | //vector<string> split(const string &str, char delim)
|
---|
20 | //{
|
---|
21 | // vector<string> result;
|
---|
22 | // size_t current = 0;
|
---|
23 | // size_t found;
|
---|
24 | // while ((found = str.find_first_of(delim, current)) != string::npos) {
|
---|
25 | // result.push_back(string(str, current, found - current));
|
---|
26 | // current = found + 1;
|
---|
27 | // }
|
---|
28 | // result.push_back(string(str, current, str.size() - current));
|
---|
29 | // return result;
|
---|
30 | //}
|
---|
31 | //} // anonymous namespace
|
---|
32 |
|
---|
33 | namespace asap {
|
---|
34 | class STIdxIter2
|
---|
35 | {
|
---|
36 | public:
|
---|
37 | template<class T>
|
---|
38 | static void Iterate(T &processor, const string cols_list)
|
---|
39 | {
|
---|
40 | vector<string> cols = split(cols_list, ',');
|
---|
41 | // for (vector<string>::iterator i = cols.begin(); i != cols.end(); ++i)
|
---|
42 | // cout << *i << endl;
|
---|
43 | STIdxIter2 iter(processor.target(), cols);
|
---|
44 | STSelector sel ;
|
---|
45 | while ( !iter.pastEnd() ) {
|
---|
46 | const Record current = iter.currentValue() ;
|
---|
47 | Vector<uInt> rows = iter.getRows( SHARE ) ;
|
---|
48 | // any process
|
---|
49 | processor.Process(cols, current, rows);
|
---|
50 | // go next
|
---|
51 | iter.next() ;
|
---|
52 | }
|
---|
53 | }
|
---|
54 | STIdxIter2() ;
|
---|
55 | STIdxIter2( const string &name,
|
---|
56 | const vector<string> &cols ) ;
|
---|
57 | STIdxIter2( const CountedPtr<Scantable> &s,
|
---|
58 | const vector<string> &cols ) ;
|
---|
59 | virtual ~STIdxIter2() ;
|
---|
60 | Record currentValue();
|
---|
61 | Bool pastEnd() ;
|
---|
62 | void next() ;
|
---|
63 | Vector<uInt> getRows(StorageInitPolicy policy=COPY) ;
|
---|
64 | vector<uInt> getRowsSTL() { return tovector( getRows() ) ; } ;
|
---|
65 | virtual void init();
|
---|
66 | private:
|
---|
67 | static vector<string> split(const string &str, char delim)
|
---|
68 | {
|
---|
69 | vector<string> result;
|
---|
70 | size_t current = 0;
|
---|
71 | size_t found;
|
---|
72 | while ((found = str.find_first_of(delim, current)) != string::npos) {
|
---|
73 | result.push_back(string(str, current, found - current));
|
---|
74 | current = found + 1;
|
---|
75 | }
|
---|
76 | result.push_back(string(str, current, str.size() - current));
|
---|
77 | return result;
|
---|
78 | }
|
---|
79 | vector<uInt> tovector(Vector<uInt> v);
|
---|
80 | void addSortKey(const string &name);
|
---|
81 | template<class T, DataType U> void addColumnToKey(const string &name);
|
---|
82 | void addColumnToKeyTpString(const string &name);
|
---|
83 | void deallocate();
|
---|
84 | vector<string> cols_;
|
---|
85 | Table table_;
|
---|
86 | uInt counter_;
|
---|
87 | uInt num_iter_;
|
---|
88 | uInt num_row_;
|
---|
89 | Sort sorter_;
|
---|
90 | Vector<uInt> index_;
|
---|
91 | Vector<uInt> unique_;
|
---|
92 | vector<void*> pointer_;
|
---|
93 | vector<Vector<String> > string_storage_;
|
---|
94 | } ;
|
---|
95 |
|
---|
96 | } // namespace
|
---|
97 | #endif /* _ASAP_INDEX_ITERATOR_H_ */
|
---|