source: branches/casa-release-4_3/src/STIdxIter.h@ 3120

Last change on this file since 3120 was 2921, checked in by Takeshi Nakazato, 11 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: Replaced C++ implementation of python iterator with

STIdxIter2 (was STIdxIterAcc)

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Removed STIdxIter classes except STIdxIter2. Implementation of Python
iterator is replaced with STIdxITer2.


File size: 2.3 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 <casa/Utilities/Sort.h>
12
13#include "Scantable.h"
14
15using namespace std ;
16using namespace casa ;
17
18namespace {
19vector<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
33namespace asap {
34class STIdxIter2
35{
36public:
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();
66private:
67 vector<uInt> tovector(Vector<uInt> v);
68 void addSortKey(const string &name);
69 template<class T, DataType U> void addColumnToKey(const string &name);
70 void addColumnToKeyTpString(const string &name);
71 void deallocate();
72 vector<string> cols_;
73 Table table_;
74 uInt counter_;
75 uInt num_iter_;
76 uInt num_row_;
77 Sort sorter_;
78 Vector<uInt> index_;
79 Vector<uInt> unique_;
80 vector<void*> pointer_;
81 vector<Vector<String> > string_storage_;
82} ;
83
84} // namespace
85#endif /* _ASAP_INDEX_ITERATOR_H_ */
Note: See TracBrowser for help on using the repository browser.