File: arraycolumniterator.h

package info (click to toggle)
aoflagger 2.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,232 kB
  • sloc: cpp: 61,805; python: 60; sh: 23; makefile: 8
file content (73 lines) | stat: -rw-r--r-- 2,009 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef ARRAYCOLUMNITERATOR_H
#define ARRAYCOLUMNITERATOR_H

#include <casacore/ms/MeasurementSets/MSColumns.h>
#include <casacore/tables/Tables/RefRows.h>

template<typename T>
class ROArrayColumnIterator {
	public:
		ROArrayColumnIterator(class casacore::ROArrayColumn<T> &column, unsigned row) noexcept :
			_column(column), _row(row)
		{
		}
		ROArrayColumnIterator(const ROArrayColumnIterator<T> &source) noexcept :
			_column(source._column), _row(source._row)
		{
		}
		~ROArrayColumnIterator() noexcept
		{
		}
		ROArrayColumnIterator<T> &operator++() noexcept {
			_row++;
			return *this;
		}
		casacore::Array<T> *operator->() const noexcept {
			return &_column(_row);
		}
		casacore::Array<T> operator*() const noexcept {
			return _column(_row);
		}
		void Set(const casacore::Array<T> &values) noexcept {
			_column.putColumnCells(casacore::RefRows(_row, _row), values);
		}
		bool operator!=(const ROArrayColumnIterator<T> &other) const noexcept {
			return _row!=other._row;
		}
		bool operator==(const ROArrayColumnIterator<T> &other) const noexcept {
			return _row==other._row;
		}
		static ROArrayColumnIterator First(casacore::ROArrayColumn<T> &column)
		{
			return ROArrayColumnIterator<T>(column, 0);
		}
	protected:
		casacore::ROArrayColumn<T> &_column;
		unsigned _row;
};

template<typename T>
class ArrayColumnIterator : public ROArrayColumnIterator<T> {
	public:
		ArrayColumnIterator(class casacore::ArrayColumn<T> &column, unsigned row) noexcept :
			ROArrayColumnIterator<T>(column, row)
		{
		}
		ArrayColumnIterator(const ArrayColumnIterator<T> &source) noexcept :
			ROArrayColumnIterator<T>(source)
		{
		}
		~ArrayColumnIterator() noexcept
		{
		}
		void Set(const casacore::Array<T> &values) noexcept {
			casacore::ArrayColumn<T> *col = static_cast<casacore::ArrayColumn<T>* >(&this->_column);
			col->basePut(this->_row, values);
		}
		static ArrayColumnIterator First(casacore::ArrayColumn<T> &column)
		{
			return ArrayColumnIterator<T>(column, 0);
		}
};

#endif