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