#ifndef _ASAP_INDEX_ITERATOR_H_ #define _ASAP_INDEX_ITERATOR_H_ #include #include #include #include #include #include #include #include "Scantable.h" using namespace std ; using namespace casacore; //namespace { //vector split(const string &str, char delim) //{ // vector result; // size_t current = 0; // size_t found; // while ((found = str.find_first_of(delim, current)) != string::npos) { // result.push_back(string(str, current, found - current)); // current = found + 1; // } // result.push_back(string(str, current, str.size() - current)); // return result; //} //} // anonymous namespace namespace asap { class STIdxIter2 { public: template static void Iterate(T &processor, const string cols_list) { vector cols = split(cols_list, ','); // for (vector::iterator i = cols.begin(); i != cols.end(); ++i) // cout << *i << endl; STIdxIter2 iter(processor.target(), cols); STSelector sel ; while ( !iter.pastEnd() ) { const Record current = iter.currentValue() ; Vector rows = iter.getRows( SHARE ) ; // any process processor.Process(cols, current, rows); // go next iter.next() ; } } STIdxIter2() ; STIdxIter2( const string &name, const vector &cols ) ; STIdxIter2( const CountedPtr &s, const vector &cols ) ; virtual ~STIdxIter2() ; Record currentValue(); Bool pastEnd() ; void next() ; Vector getRows(StorageInitPolicy policy=COPY) ; vector getRowsSTL() { return tovector( getRows() ) ; } ; virtual void init(); private: static vector split(const string &str, char delim) { vector result; size_t current = 0; size_t found; while ((found = str.find_first_of(delim, current)) != string::npos) { result.push_back(string(str, current, found - current)); current = found + 1; } result.push_back(string(str, current, str.size() - current)); return result; } vector tovector(Vector v); void addSortKey(const string &name); template void addColumnToKey(const string &name); void addColumnToKeyTpString(const string &name); void deallocate(); vector cols_; Table table_; uInt counter_; uInt num_iter_; uInt num_row_; Sort sorter_; Vector index_; Vector unique_; vector pointer_; vector > string_storage_; } ; } // namespace #endif /* _ASAP_INDEX_ITERATOR_H_ */