//# ArrayColumn.cc: Access to an array table column with arbitrary data type //# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id: ArrayColumn.tcc 21562 2015-02-16 07:03:44Z gervandiepen $ #ifndef TABLES_ARRAYCOLUMN_TCC #define TABLES_ARRAYCOLUMN_TCC #include #include #include #include #include #include #include #include #include #include #include #include namespace casacore { //# NAMESPACE CASACORE - BEGIN template ArrayColumn::ArrayColumn() : ArrayColumnBase () {} template ArrayColumn::ArrayColumn (const Table& tab, const String& columnName) : ArrayColumnBase (tab, columnName) { checkDataType(); } template ArrayColumn::ArrayColumn (const TableColumn& column) : ArrayColumnBase (column) { checkDataType(); } template ArrayColumn::ArrayColumn (const ArrayColumn& that) : ArrayColumnBase (that) {} template TableColumn* ArrayColumn::clone() const { return new ArrayColumn (*this); } template ArrayColumn& ArrayColumn::operator= (const ArrayColumn& that) { reference (that); return (*this); } template void ArrayColumn::reference (const ArrayColumn& that) { TableColumn::reference (that); } template ArrayColumn::~ArrayColumn() {} template void ArrayColumn::checkDataType() const { //# Check if the data type matches. const ColumnDesc& cd = baseColPtr_p->columnDesc(); DataType dtype = cd.dataType(); if (dtype != ValType::getType(static_cast(0)) || !cd.isArray()) { throw (TableInvDT (" in ArrayColumn ctor for column " + cd.name())); } if (dtype == TpOther) { if (cd.dataTypeId() != valDataTypeId(static_cast(0))) { throw (TableInvDT (" in ArrayColumn ctor for column " + cd.name() + "; using data type id " + valDataTypeId(static_cast(0)) + ", expected " + cd.dataTypeId())); } } } template Array ArrayColumn::operator() (rownr_t rownr) const { Array arr; get (rownr, arr); return arr; } template Array ArrayColumn::get (rownr_t rownr) const { Array arr; get (rownr, arr); return arr; } template void ArrayColumn::get (rownr_t rownr, Array& arr, Bool resize) const { acbGet (rownr, arr, resize); } template Array ArrayColumn::getSlice (rownr_t rownr, const Slicer& arraySection) const { Array arr; getSlice (rownr, arraySection, arr); return arr; } template void ArrayColumn::getSlice (rownr_t rownr, const Slicer& arraySection, Array& arr, Bool resize) const { acbGetSlice (rownr, arraySection, arr, resize); } template Array ArrayColumn::getSlice (rownr_t rownr, const Vector >& arraySlices) const { Array arr; getSlice (rownr, arraySlices, arr); return arr; } template void ArrayColumn::getSlice (rownr_t rownr, const Vector >& arraySlices, Array& arr, Bool resize) const { acbGetSlice (rownr, arraySlices, arr, resize); } template void ArrayColumn::getColumnCells (const RefRows& rows, const ColumnSlicer& columnSlicer, Array& destination, Bool resize) const { acbGetColumnCells (rows, columnSlicer, destination, resize); } //template //void //ArrayColumn::getColumnCellsSlicers (const Vector > & arraySlices, // uInt axis, // Vector selections, // vector result) const //{ // if (axis == arraySlices.size()){ // // IPosition start (axis), increment (axis), length (axis); // // for (uInt i = 0; i < axis; i++){ // // const Slice & slice = arraySlices [i] [selections [i]]; // start [i] = slice.start(); // increment [i] = slice.inc(); // length [i] = slice.length(); // // result.push_back = new Slicer (start, length, increment); // // } // // return; // } // // const Vector & thisAxis = arraySlices [axis]; // // for (uInt i = 0; i < thisAxis.size(); i++){ // // selections [axis] = i; // getColumnCellsSlicers (arraySlices, axis + 1, selections, result); // } // //} template Array ArrayColumn::getColumn() const { Array arr; getColumn (arr); return arr; } template void ArrayColumn::getColumn (Array& arr, Bool resize) const { acbGetColumn (arr, resize); } template Array ArrayColumn::getColumn (const Slicer& arraySection) const { Array arr; getColumn (arraySection, arr); return arr; } template void ArrayColumn::getColumn (const Slicer& arraySection, Array& arr, Bool resize) const { acbGetColumn (arraySection, arr, resize); } template Array ArrayColumn::getColumn (const Vector >& arraySlices) const { Array arr; getColumn (arraySlices, arr); return arr; } template void ArrayColumn::getColumn (const Vector >& arraySlices, Array& arr, Bool resize) const { acbGetColumn (arraySlices, arr, resize); } template Array ArrayColumn::getColumnRange (const Slicer& rowRange) const { Array arr; getColumnRange (rowRange, arr); return arr; } template void ArrayColumn::getColumnRange (const Slicer& rowRange, Array& arr, Bool resize) const { acbGetColumnRange (rowRange, arr, resize); } template Array ArrayColumn::getColumnCells (const RefRows& rownrs) const { Array arr; getColumnCells (rownrs, arr); return arr; } template void ArrayColumn::getColumnCells (const RefRows& rownrs, Array& arr, Bool resize) const { acbGetColumnCells (rownrs, arr, resize); } template Array ArrayColumn::getColumnRange (const Slicer& rowRange, const Slicer& arraySection) const { Array arr; getColumnRange (rowRange, arraySection, arr); return arr; } template void ArrayColumn::getColumnRange (const Slicer& rowRange, const Slicer& arraySection, Array& arr, Bool resize) const { acbGetColumnRange (rowRange, arraySection, arr, resize); } template Array ArrayColumn::getColumnCells (const RefRows& rownrs, const Slicer& arraySection) const { Array arr; getColumnCells (rownrs, arraySection, arr); return arr; } template void ArrayColumn::getColumnCells (const RefRows& rownrs, const Slicer& arraySection, Array& arr, Bool resize) const { acbGetColumnCells (rownrs, arraySection, arr, resize); } template void ArrayColumn::setShape (rownr_t rownr, const IPosition& shape) { ArrayColumnBase::setShape (rownr, shape); } template void ArrayColumn::setShape (rownr_t rownr, const IPosition& shape, const IPosition& tileShape) { ArrayColumnBase::setShape (rownr, shape, tileShape); } template void ArrayColumn::put (rownr_t rownr, const Array& arr) { acbPut (rownr, arr); } template void ArrayColumn::putSlice (rownr_t rownr, const Slicer& arraySection, const Array& arr) { acbPutSlice (rownr, arraySection, arr); } template void ArrayColumn::putSlice (rownr_t rownr, const Vector >& arraySlices, const Array& arr) { acbPutSlice (rownr, arraySlices, arr); } template void ArrayColumn::putColumnCells (const RefRows& rows, const Vector >& arraySlices, const Array& source) { acbPutColumnCells (rows, arraySlices, source); } template void ArrayColumn::putColumnCells (const RefRows& rows, const ColumnSlicer& columnSlicer, const Array& source) { acbPutColumnCells (rows, columnSlicer, source); } template void ArrayColumn::put (rownr_t thisRownr, const TableColumn& that, rownr_t thatRownr, Bool preserveTileShape) { TableColumn::put (thisRownr, that, thatRownr, preserveTileShape); } template void ArrayColumn::putColumn (const Array& arr) { acbPutColumn (arr); } template void ArrayColumn::putColumn (const Slicer& arraySection, const Array& arr) { acbPutColumn (arraySection, arr); } template void ArrayColumn::putColumn (const Vector >& arraySlices, const Array& arr) { acbPutColumn (arraySlices, arr); } template void ArrayColumn::putColumnRange (const Slicer& rowRange, const Array& arr) { acbPutColumnRange (rowRange, arr); } template void ArrayColumn::putColumnCells (const RefRows& rownrs, const Array& arr) { acbPutColumnCells (rownrs, arr); } template void ArrayColumn::putColumnRange (const Slicer& rowRange, const Slicer& arraySection, const Array& arr) { acbPutColumnRange (rowRange, arraySection, arr); } template void ArrayColumn::putColumnCells (const RefRows& rownrs, const Slicer& arraySection, const Array& arr) { acbPutColumnCells (rownrs, arraySection, arr); } //# This is a very simple implementation. //# However, it does not need to be more fancy, since an array operation //# is already much more expensive than the virtual function calls //# involved in each loop iteration. template void ArrayColumn::fillColumn (const Array& value) { acbFillColumn (value); } template void ArrayColumn::putColumn (const ArrayColumn& that) { acbPutColumn (that); } } //# NAMESPACE CASACORE - END #endif