casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TBTest.h
Go to the documentation of this file.
1 //# TBTest.h: Tests to check the validity of a table.
2 //# Copyright (C) 2005
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef TBTEST_H_
28 #define TBTEST_H_
29 
30 #include <vector>
31 
32 #include <casa/BasicSL/String.h>
33 
34 namespace casa {
35 
36 //# Forward Declarations
37 class TBBrowser;
38 
39 // <summary>
40 // Tests to check the validity of a table.
41 // </summary>
42 //
43 // <synopsis>
44 // TBTest is an abstract superclass for any class that wants to test the
45 // validity of a table. A "test" can be thought of as a series of checks, or
46 // smaller tests. Although currently only basic tests are implemented, more
47 // complex tests could be added in the future; for example, a check to make
48 // sure the table has a valid structure if it is a Measurement Set.
49 // </synopsis>
50 
51 class TBTest {
52 public:
53  // Constructor that takes the browser parent and the name of the test.
55 
56  virtual ~TBTest();
57 
58 
59  // Returns the name of the test.
61 
62 
63  // checks() must be implemented by any subclass.
64  // Returns a list of the names of the checks in this test, given the name
65  // of the table on which the test will be run.
66  virtual std::vector<casacore::String> checks(casacore::String table) = 0;
67 
68  // runCheck() must be implemented by any subclass.
69  // Runs the given check on the given table and returns the result.
70  virtual bool runCheck(casacore::String table, int i) = 0;
71 
72 protected:
73  // Browser parent.
75 
76  // Name of the test.
78 };
79 
80 // <summary>
81 // Tests whether fields ending in _ID have a corresponding subtable.
82 // </summary>
83 
84 class TBIDFieldsTest : public TBTest {
85 public:
86  // Constructor that takes the browser parent.
88 
90 
91  // Implements TBTest::checks().
92  // For each field ending in _ID: "Field [name]_ID has corresponding table
93  // keyword [name]."
94  std::vector<casacore::String> checks(casacore::String table);
95 
96  // Implements TBTest::runCheck().
97  bool runCheck(casacore::String table, int i);
98 };
99 
100 // <summary>
101 // Tests whether subtables exist on disk.
102 // </summary>
103 
104 class TBSubtablesTest : public TBTest {
105 public:
106  // Constructor that takes the browser parent.
108 
110 
111  // Implements TBTest::checks().
112  // For each subtable in the keywords: "Subtable [name] exists on disk at
113  // [location]."
114  std::vector<casacore::String> checks(casacore::String table);
115 
116  // Implements TBTest::runCheck().
117  bool runCheck(casacore::String table, int i);
118 };
119 
120 // <summary>
121 // Tests whether subtables can be opened and have data.
122 // </summary>
123 
124 class TBValidSubtablesTest : public TBTest {
125 public:
126  // Constructor that takes the browser parent.
128 
130 
131  // Implements TBTest::checks().
132  // For each subtable in the keywords: "Subtable [name] can be opened and
133  // has at least one row of data."
134  std::vector<casacore::String> checks(casacore::String table);
135 
136  // Implements TBTest::runCheck().
137  bool runCheck(casacore::String table, int i);
138 };
139 
140 }
141 
142 #endif /* TBTEST_H_ */
Tests whether subtables can be opened and have data.
Definition: TBTest.h:124
Tests to check the validity of a table.
Definition: TBTest.h:51
Browser widget for managing opened tables.
Definition: TBBrowser.qo.h:63
virtual std::vector< casacore::String > checks(casacore::String table)=0
checks() must be implemented by any subclass.
casacore::String name
Name of the test.
Definition: TBTest.h:77
std::vector< casacore::String > checks(casacore::String table)
Implements TBTest::checks().
virtual bool runCheck(casacore::String table, int i)=0
runCheck() must be implemented by any subclass.
virtual ~TBTest()
casacore::String getName()
Returns the name of the test.
TBSubtablesTest(TBBrowser *browser)
Constructor that takes the browser parent.
std::vector< casacore::String > checks(casacore::String table)
Implements TBTest::checks().
TBTest(TBBrowser *browser, casacore::String name)
Constructor that takes the browser parent and the name of the test.
Tests whether fields ending in _ID have a corresponding subtable.
Definition: TBTest.h:84
Tests whether subtables exist on disk.
Definition: TBTest.h:104
bool runCheck(casacore::String table, int i)
Implements TBTest::runCheck().
TBIDFieldsTest(TBBrowser *browser)
Constructor that takes the browser parent.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
bool runCheck(casacore::String table, int i)
Implements TBTest::runCheck().
std::vector< casacore::String > checks(casacore::String table)
Implements TBTest::checks().
TBValidSubtablesTest(TBBrowser *browser)
Constructor that takes the browser parent.
bool runCheck(casacore::String table, int i)
Implements TBTest::runCheck().
TBBrowser * browser
Browser parent.
Definition: TBTest.h:74