casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MSFieldIndex.h
Go to the documentation of this file.
00001 //# MSFieldIndex: index or lookup in a MeasurementSet FIELD subtable
00002 //# Copyright (C) 2000,2001
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 //# $Id: MSFieldIndex.h 20266 2008-02-26 00:43:05Z gervandiepen $
00028 
00029 #ifndef MS_MSFIELDINDEX_H
00030 #define MS_MSFIELDINDEX_H
00031 
00032 //# includes
00033 #include <casa/aips.h>
00034 #include <ms/MeasurementSets/MSField.h>
00035 #include <ms/MeasurementSets/MSSelectionError.h>
00036 #include <ms/MeasurementSets/MSFieldColumns.h>
00037 #include <casa/Arrays/Vector.h>
00038 #include <casa/BasicSL/String.h>
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 
00042 //# forward declarations
00043 
00044 // <summary>
00045 // Class to handle lookup or indexing into a MS FIELD subtable
00046 // </summary>
00047 
00048 // <use visibility=export>
00049 //
00050 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00051 // </reviewed>
00052 
00053 // <prerequisite>
00054 //   <li> MeasurementSet
00055 //   <li> MSField
00056 // </prerequisite>
00057 //
00058 // <etymology>
00059 // From "MeasurementSet", "FIELD subtable" and "index".
00060 // </etymology>
00061 //
00062 // <synopsis>
00063 // This class provides lookup and indexing into an MS FIELD
00064 // subtable. These services include returning rows numbers
00065 // (which for the FIELD subtable are FIELD_ID's) associated 
00066 // with specific data in the subtable.
00067 // </synopsis>
00068 //
00069 // <example>
00070 // </example>
00071 //
00072 // <motivation>
00073 // Collect together all subtable indexing and lookup for the
00074 // FIELD subtable, for encapsulation and efficiency.
00075 // </motivation>
00076 //
00077 // <thrown>
00078 //    <li>
00079 //    <li>
00080 // </thrown>
00081 //
00082 
00083 class MSFieldIndex 
00084 {
00085 public:
00086   // Construct from an MS FIELD subtable
00087   MSFieldIndex(const MSField &field);
00088 
00089   // Null destructor
00090   virtual ~MSFieldIndex() {};
00091 
00092   // Look up a single name in FIELD.NAME or FIELD.CODE
00093   Vector<Int> matchFieldNameOrCode(const String& name);
00094   // Look up FIELD_ID's for a given field name, or set of field names
00095   Vector<Int> matchFieldName(const String& name);
00096   Vector<Int> matchFieldName(const Vector<String>& names);
00097 
00098   //ADD for file name wildcard selection
00099   Vector<Int> matchSubFieldName(const String& name);
00100 
00101   // Look up FIELD_ID's for a given pattern/regex for source name/code
00102   Vector<Int> matchFieldRegexOrPattern(const String& pattern,
00103                                        const Bool regex=False);
00104   Vector<Int> matchFieldNameRegexOrPattern(const String& pattern,
00105                                            const Bool regex=False);
00106   Vector<Int> matchFieldCodeRegexOrPattern(const String& pattern,
00107                                            const Bool regex=False);
00108   // Look up FIELD_ID's for a given source id
00109   Vector<Int> matchSourceId(const Int& sourceId);
00110   Vector<Int> matchSourceId(const Vector<Int>& sourceIds);
00111   Vector<Int> validateIndices(const Vector<Int>& sourceIds);
00112 
00113   // Add for field code selection
00114   Vector<Int> matchFieldCode(const String& code);
00115 
00116   Vector<Int> maskFieldIDs(const Vector<Int>& ids);
00117 
00118   Vector<Int> matchFieldIDLT(const Int n);
00119   Vector<Int> matchFieldIDGT(const Int n);
00120   Vector<Int> matchFieldIDGTAndLT(const Int n0, const int n1);
00121 private:
00122   // Disallow null constructor
00123   MSFieldIndex();
00124 
00125   // FIELD subtable column accessor
00126   ROMSFieldColumns msFieldCols_p;
00127 
00128   // Vector cache of field id's
00129   Vector<Int> fieldIds_p;
00130   Int nrows_p;
00131 };
00132 
00133 
00134 } //# NAMESPACE CASA - END
00135 
00136 #endif
00137