#ifndef _ASAP_INDEX_ITERATOR_H_ #define _ASAP_INDEX_ITERATOR_H_ #include #include #include #include #include #include "Scantable.h" using namespace std ; using namespace casa ; namespace asap { class IndexIterator { public: IndexIterator( IPosition &shape ) ; Block current() { return idx_m ; } ; Bool pastEnd() ; void next() ; private: uInt nfield_m ; Block prod_m ; Block idx_m ; uInt niter_m ; uInt maxiter_m ; } ; class ArrayIndexIterator { public: ArrayIndexIterator( Matrix &arr, vector< vector > idlist=vector< vector >() ) ; virtual ~ArrayIndexIterator() ; Vector current() ; Bool pastEnd() ; virtual void next() = 0 ; virtual Vector getRows( StorageInitPolicy policy=COPY ) = 0 ; protected: IndexIterator *iter_m ; uInt nrow_m ; uInt ncol_m ; Block storage_m ; Matrix arr_m ; IPosition pos_m ; Vector current_m ; vector< vector > idxlist_m ; } ; class ArrayIndexIteratorNormal : public ArrayIndexIterator { public: ArrayIndexIteratorNormal( Matrix &arr, vector< vector > idlist=vector< vector >() ) ; void next() ; Vector getRows( StorageInitPolicy policy=COPY ) ; } ; class ArrayIndexIteratorAcc : public ArrayIndexIterator { public: ArrayIndexIteratorAcc( Matrix &arr, vector< vector > idlist=vector< vector >() ) ; void next() ; Vector getRows( StorageInitPolicy policy=COPY ) ; private: Int isChanged( Block &idx ) ; uInt *updateStorage( Int &icol, uInt *base, uInt &v ) ; Block prev_m ; Block len_m ; Block skip_m ; } ; class STIdxIter { public: STIdxIter() ; STIdxIter( const string &name, const vector &cols ) ; STIdxIter( const CountedPtr &s, const vector &cols ) ; virtual ~STIdxIter() ; vector currentSTL() { return tovector( iter_m->current() ) ; } ; Vector current() { return iter_m->current() ; } ; Bool pastEnd() { return iter_m->pastEnd() ; } ; void next() { iter_m->next() ; } ; vector getRowsSTL() { return tovector( iter_m->getRows() ) ; } ; // !!!you should not use policy=TAKE_OVER since it causes problem!!! Vector getRows( StorageInitPolicy policy=COPY ) ; protected: ArrayIndexIterator *iter_m ; virtual void init( Table &t, const vector &cols ) = 0 ; private: vector tovector( Vector v ) ; } ; class STIdxIterNormal : public STIdxIter { public: STIdxIterNormal() ; STIdxIterNormal( const string &name, const vector &cols ) ; STIdxIterNormal( const CountedPtr &s, const vector &cols ) ; ~STIdxIterNormal() ; protected: void init( Table &t, const vector &cols ) ; } ; class STIdxIterAcc : public STIdxIter { public: STIdxIterAcc() ; STIdxIterAcc( const string &name, const vector &cols ) ; STIdxIterAcc( const CountedPtr &s, const vector &cols ) ; ~STIdxIterAcc() ; protected: virtual void init( Table &t, const vector &cols ) ; } ; // class STIdxIterExAcc : public STIdxIterAcc // { // STIdxIterExAcc() ; // STIdxIterExAcc( const string &name, // const vector &cols ) ; // STIdxIterExAcc( const CountedPtr &s, // const vector &cols ) ; // ~STIdxIterExAcc() ; // protected: // virtual void init( Table &t, // const vector &cols ) ; // } ; } // namespace #endif /* _ASAP_INDEX_ITERATOR_H_ */