source: trunk/src/STIdxIter.h@ 3104

Last change on this file since 3104 was 3078, checked in by Takeshi Nakazato, 9 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes/No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...


Make STIdxIter2 warning free. Utility function split is defined inside STIdxIter2 since it is not used outside the class. If it is useful, it will be separated from the class.

File size: 2.7 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
[2911]11#include <casa/Utilities/Sort.h>
12
[2519]13#include "Scantable.h"
14
15using namespace std ;
16using namespace casa ;
17
[3078]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
[2920]32
[2519]33namespace asap {
[2911]34class STIdxIter2
35{
36public:
[2920]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 }
[2911]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:
[3078]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 }
[2911]79 vector<uInt> tovector(Vector<uInt> v);
80 void addSortKey(const string &name);
81 template<class T, DataType U> void addColumnToKey(const string &name);
[2918]82 void addColumnToKeyTpString(const string &name);
[2911]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_;
[2918]93 vector<Vector<String> > string_storage_;
[2911]94} ;
95
[2519]96} // namespace
97#endif /* _ASAP_INDEX_ITERATOR_H_ */
Note: See TracBrowser for help on using the repository browser.