Vi2StatsFlagsIterator.h

Go to the documentation of this file.
00001 // -*- mode: c++ -*-
00002 //# Copyright (C) 1996,1997,1998,1999,2000,2002,2003,2015
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //
00027 // Data provider mask iterators, based on a flag column.
00028 //
00029 #ifndef MSVIS_STATISTICS_VI2_STATS_FLAGS_ITERATOR_H_
00030 #define MSVIS_STATISTICS_VI2_STATS_FLAGS_ITERATOR_H_
00031 
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/casa/Arrays/Array.h>
00034 #include <msvis/MSVis/VisibilityIterator2.h>
00035 #include <msvis/MSVis/VisBuffer2.h>
00036 #include <memory>
00037 #include <iterator>
00038 
00039 namespace casa {
00040 
00041 // Vi2StatsFlagsIterator has the form of a CRTP base class to promote
00042 // efficiency in iterator operations.
00043 //
00044 template <class T>
00045 class Vi2StatsFlagsIterator
00046         : public std::iterator<std::input_iterator_tag,Bool> {
00047 
00048 public:
00049         Vi2StatsFlagsIterator& operator++();
00050 
00051         Vi2StatsFlagsIterator operator++(int);
00052 
00053         bool operator==(const Vi2StatsFlagsIterator& rhs);
00054 
00055         bool operator!=(const Vi2StatsFlagsIterator& rhs);
00056 
00057         Bool operator*();
00058 
00059         bool atEnd();
00060 
00061 protected:
00062         Vi2StatsFlagsIterator()
00063                 : flags_array(&empty_array)
00064                 , flags_iter(empty_array.begin())
00065                 , end_iter(empty_array.end()) {};
00066 
00067         const Array<Bool>* flags_array;
00068 
00069         Array<Bool>::const_iterator flags_iter;
00070 
00071         Array<Bool>::const_iterator end_iter;
00072 
00073         static const Array<Bool> empty_array;
00074 };
00075 
00076 template <class T>
00077 const Array<Bool> Vi2StatsFlagsIterator<T>::empty_array;
00078 
00079 // Mask iterator over flag cube. If the flag cube column is not present, this
00080 // iterator will provide values as if the flag cube were present by replicating
00081 // flag row values in order to mimic the shape of the flag cube.
00082 class Vi2StatsFlagsCubeIterator final
00083         : public Vi2StatsFlagsIterator<Vi2StatsFlagsCubeIterator> {
00084 public:
00085         Vi2StatsFlagsCubeIterator(vi::VisBuffer2 *vb2);
00086 
00087         Vi2StatsFlagsCubeIterator();
00088 
00089         Vi2StatsFlagsCubeIterator& operator++();
00090 
00091         Vi2StatsFlagsCubeIterator operator++(int);
00092 
00093         bool operator==(const Vi2StatsFlagsCubeIterator& rhs);
00094 
00095         bool operator!=(const Vi2StatsFlagsCubeIterator& rhs);
00096 
00097         Bool operator*();
00098 
00099         bool atEnd();
00100 
00101 protected:
00102         uInt expansion_factor;
00103 
00104 private:
00105         uInt replicate_count;
00106 };
00107 
00108 // Mask iterator over row flags. If the row flags column is not present, this
00109 // iterator will provide values as if the row flags column were present by
00110 // reducing the flag cube values to mimic the shape of the flag row column.
00111 class Vi2StatsFlagsRowIterator final
00112         : public Vi2StatsFlagsIterator<Vi2StatsFlagsRowIterator> {
00113 public:
00114         Vi2StatsFlagsRowIterator(vi::VisBuffer2 *vb2);
00115 
00116         Vi2StatsFlagsRowIterator();
00117 
00118         Vi2StatsFlagsRowIterator& operator++();
00119 
00120         Vi2StatsFlagsRowIterator operator++(int);
00121 
00122         bool operator==(const Vi2StatsFlagsRowIterator& rhs);
00123 
00124         bool operator!=(const Vi2StatsFlagsRowIterator& rhs);
00125 
00126         Bool operator*();
00127 
00128         bool atEnd();
00129 
00130 protected:
00131         uInt reduction_factor;
00132 
00133 private:
00134         Bool rowFlag;
00135         void prepareNextRow();
00136 };
00137 
00138 } // namespace casa
00139 
00140 
00141 #endif // MSVIS_STATISTICS_VI2_STATS_FLAGS_ITERATOR_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1