//# RFASelector.cc: this defines RFASelector //# Copyright (C) 2000,2001,2002 //# 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$ #include #include #include #include #include #include #include #include #include #include #include #include namespace casa { //# NAMESPACE CASA - BEGIN // ----------------------------------------------------------------------- // reformRange // Reforms an array of 2N elements into a [2,N] matrix // ----------------------------------------------------------------------- template casacore::Bool RFASelector::reformRange( casacore::Matrix &rng,const casacore::Array &arr ) { if( arr.ndim()>2 || (arr.nelements()%2) !=0 ) return false; rng = arr.reform(casacore::IPosition(2,2,arr.nelements()/2)); return true; } template casacore::Array fieldToArray( const casacore::RecordInterface &parm,const casacore::String &id ); /* template<> casacore::Array fieldToArray( const casacore::RecordInterface &parm,const casacore::String &id ) { return parm.toArrayInt(id); } template<> casacore::Array fieldToArray( const casacore::RecordInterface &parm,const casacore::String &id ) { return parm.toArrayDouble(id); } template<> casacore::Array fieldToArray( const casacore::RecordInterface &parm,const casacore::String &id ) { return parm.toArrayString(id); } */ // ----------------------------------------------------------------------- // RFASelector::parseRange // Returns a record field of 2N elements as a [2,N] matrix // ----------------------------------------------------------------------- template casacore::Bool RFASelector::parseRange( casacore::Matrix &rng,const casacore::RecordInterface &parm,const casacore::String &id ) { if( isFieldSet(parm,id) ) { try { casacore::Array arr( fieldToArray(parm,id) ); if( !reformRange(rng,arr) ) throw( casacore::AipsError("") ); return true; } catch( casacore::AipsError x ) { os<<"Illegal \""<( casacore::Matrix&,const casacore::Array& ); template casacore::Bool RFASelector::reformRange( casacore::Matrix&,const casacore::Array& ); template casacore::Bool RFASelector::reformRange( casacore::Matrix&,const casacore::Array& ); template casacore::Bool RFASelector::parseRange( casacore::Matrix&,const casacore::RecordInterface&,const casacore::String&); template casacore::Bool RFASelector::parseRange( casacore::Matrix&,const casacore::RecordInterface&,const casacore::String&); template casacore::Bool RFASelector::parseRange( casacore::Matrix&,const casacore::RecordInterface&,const casacore::String&); */ // ----------------------------------------------------------------------- // RFA_selector::find // Helper templated method to find an object in an array // ----------------------------------------------------------------------- template casacore::Bool RFASelector::find( casacore::uInt &index,const T &obj,const casacore::Vector &arr ) { for( casacore::uInt i=0; i(casacore::uInt&,const casacore::uInt&,const casacore::Vector&); template casacore::Bool RFASelector::find(casacore::uInt&,const casacore::Int&,const casacore::Vector&); template casacore::Bool RFASelector::find(casacore::uInt&,const casacore::String&,const casacore::Vector&); */ } //# NAMESPACE CASA - END