casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PassiveTableDD.h
Go to the documentation of this file.
00001 //# PassiveTableDD.h: PassiveCachingDD class with Table-specific support
00002 //# Copyright (C) 2000
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 //# $Id$
00027 
00028 #ifndef TRIALDISPLAY_PASSIVETABLEDD_H
00029 #define TRIALDISPLAY_PASSIVETABLEDD_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/Arrays/Vector.h>
00033 #include <casa/Containers/Record.h>
00034 #include <casa/Utilities/DataType.h>
00035 #include <display/DisplayDatas/PassiveCachingDD.h>
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 class Table;
00040 class Regex;
00041 
00042 // <summary>
00043 // Class adding Table-specific support functions to PassiveCachingDD.
00044 // </summary>
00045 
00046 // <synopsis>
00047 // This class adds support functions useful for dealing with Tables
00048 // to the PassiveCachingDD class.
00049 // </synopsis>
00050 
00051 class PassiveTableDD : public PassiveCachingDD {
00052 
00053  public:
00054 
00055   // Constructor taking a pointer to an already constructed Table.
00056   // The Table will be deleted by this class.
00057   PassiveTableDD(Table *table);
00058 
00059   // Constructor taking a String which describes the full pathname
00060   // of a Table on disk.
00061   PassiveTableDD(const String tablename);
00062 
00063   // Destructor.
00064   virtual ~PassiveTableDD();
00065 
00066   // Install the default options for this DisplayData.
00067   virtual void setDefaultOptions();
00068 
00069   // Apply options stored in <src>rec</src> to the DisplayData.  A
00070   // return value of <src>True</src> means a refresh is needed.
00071   // <src>recOut</src> contains any fields which were implicitly 
00072   // changed as a result of the call to this function.
00073   virtual Bool setOptions(Record &rec, Record &recOut);
00074 
00075   // Retrieve the current and default options and parameter types.
00076   virtual Record getOptions();
00077 
00078   // Return the current options of this DisplayData as an
00079   // AttributeBuffer.
00080   virtual AttributeBuffer optionsAsAttributes();
00081 
00082  protected:
00083 
00084   // Get the value of the named keyword, or the first keyword matching
00085   // <src>regex</src>, and return it in <src>value</src>.  The return
00086   // value is <src>True</src> for success, and <src>False</src> for
00087   // failure, which is the result if the wrong type <src>T</src> is 
00088   // requested.
00089   // <group>
00090   template <class T> Bool getTableKeyword(T &value, 
00091                                           const String keyword) const;
00092   template <class T> Bool getTableKeyword(T &value, const Regex &regex) const;
00093   // </group>
00094 
00095   // Get the value of the named keyword, or the first keyword matching
00096   // <src>regex</src> for the named column, and return it in
00097   // <src>value</src>. The return value is <src>True</src> for
00098   // success, and <src>False</src> for failure, which is the result if
00099   // the wrong type <src>T</src> is requested, or if the keyword
00100   // doesn't exist.
00101   // <group>
00102   template <class T> Bool getColumnKeyword(T &value, const String column,
00103                                            const String keyword) const;
00104   template <class T> Bool getColumnKeyword(T &value, const String column,
00105                                            const Regex &regex) const;
00106   // </group>
00107 
00108   // Get the names of the columns of the table having the given type.
00109   Vector<String> getColumnNamesOfType(const DataType type);
00110 
00111   // Return the Table pointer for use by derived classes.  If a query
00112   // is active (via <src>setOptions</src>), then the result of the
00113   // query is returned, otherwise the construction Table is returned.
00114   Table *table();
00115 
00116   // (Required) default constructor.
00117   PassiveTableDD();
00118 
00119   // (Required) copy constructor.
00120   PassiveTableDD(const PassiveTableDD &other);
00121 
00122   // (Required) copy assignment.
00123   void operator=(const PassiveTableDD &other);
00124 
00125  private:
00126 
00127   // Store the primary table here.
00128   Table *itsTable;
00129 
00130   // Store the result of a query on the table here.
00131   Table *itsQueryTable;
00132 
00133   // Option: what is the query string, or is it unset?
00134   String itsOptQueryString;
00135   Bool itsOptQueryStringUnset;
00136 
00137   // Install the default options for this DisplayData.
00138   void installDefaultOptions();
00139 
00140   // Arrange the query table (generally called after installing new
00141   // options).
00142   Bool arrangeQueryTable();
00143 
00144 };
00145 
00146 
00147 } //# NAMESPACE CASA - END
00148 
00149 #ifndef AIPS_NO_TEMPLATE_SRC
00150 #include <display/DisplayDatas/PassiveTableDDTemplates.tcc>
00151 #endif
00152 
00153 #endif