TBTest.h

Go to the documentation of this file.
00001 //# TBTest.h: Tests to check the validity of a table.
00002 //# Copyright (C) 2005
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 #ifndef TBTEST_H_
00028 #define TBTEST_H_
00029 
00030 #include <vector>
00031 
00032 #include <casa/BasicSL/String.h>
00033 
00034 namespace casa {
00035 
00036 //# Forward Declarations
00037 class TBBrowser;
00038 
00039 // <summary>
00040 // Tests to check the validity of a table.
00041 // </summary>
00042 //
00043 // <synopsis>
00044 // TBTest is an abstract superclass for any class that wants to test the
00045 // validity of a table.  A "test" can be thought of as a series of checks, or
00046 // smaller tests.  Although currently only basic tests are implemented, more
00047 // complex tests could be added in the future; for example, a check to make
00048 // sure the table has a valid structure if it is a Measurement Set.
00049 // </synopsis>
00050 
00051 class TBTest {
00052 public:
00053         // Constructor that takes the browser parent and the name of the test.
00054     TBTest(TBBrowser* browser, String name);
00055 
00056     virtual ~TBTest();
00057 
00058     
00059     // Returns the name of the test.
00060     String getName();
00061     
00062     
00063     // checks() must be implemented by any subclass.
00064     // Returns a list of the names of the checks in this test, given the name
00065     // of the table on which the test will be run.
00066     virtual std::vector<String> checks(String table) = 0;
00067 
00068     // runCheck() must be implemented by any subclass.
00069     // Runs the given check on the given table and returns the result.
00070     virtual bool runCheck(String table, int i) = 0;
00071 
00072 protected:
00073         // Browser parent.
00074         TBBrowser* browser;
00075         
00076         // Name of the test.
00077     String name;
00078 };
00079 
00080 // <summary>
00081 // Tests whether fields ending in _ID have a corresponding subtable.
00082 // </summary>
00083 
00084 class TBIDFieldsTest : public TBTest {
00085 public:
00086         // Constructor that takes the browser parent.
00087     TBIDFieldsTest(TBBrowser* browser);
00088 
00089     ~TBIDFieldsTest();
00090 
00091     // Implements TBTest::checks().
00092     // For each field ending in _ID: "Field [name]_ID has corresponding table
00093     // keyword [name]."
00094     std::vector<String> checks(String table);
00095 
00096     // Implements TBTest::runCheck().
00097     bool runCheck(String table, int i);
00098 };
00099 
00100 // <summary>
00101 // Tests whether subtables exist on disk.
00102 // </summary>
00103 
00104 class TBSubtablesTest : public TBTest {
00105 public:
00106         // Constructor that takes the browser parent.
00107     TBSubtablesTest(TBBrowser* browser);
00108 
00109     ~TBSubtablesTest();
00110 
00111     // Implements TBTest::checks().
00112     // For each subtable in the keywords: "Subtable [name] exists on disk at 
00113     // [location]."
00114     std::vector<String> checks(String table);
00115 
00116     // Implements TBTest::runCheck().
00117     bool runCheck(String table, int i);
00118 };
00119 
00120 // <summary>
00121 // Tests whether subtables can be opened and have data.
00122 // </summary>
00123 
00124 class TBValidSubtablesTest : public TBTest {
00125 public:
00126         // Constructor that takes the browser parent.
00127     TBValidSubtablesTest(TBBrowser* browser);
00128 
00129     ~TBValidSubtablesTest();
00130 
00131     // Implements TBTest::checks().
00132     // For each subtable in the keywords: "Subtable [name] can be opened and
00133     // has at least one row of data."
00134     std::vector<String> checks(String table);
00135 
00136     // Implements TBTest::runCheck().
00137     bool runCheck(String table, int i);
00138 };
00139 
00140 }
00141 
00142 #endif /* TBTEST_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1