casacore
NullTable.h
Go to the documentation of this file.
1 //# NullTable.h: Class indicating a null Table object
2 //# Copyright (C) 2001,2002,2003
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 
28 #ifndef TABLES_NULLTABLE_H
29 #define TABLES_NULLTABLE_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/tables/Tables/BaseTable.h>
35 
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 // <summary>
40 // Class indicating a null Table object
41 // </summary>
42 
43 // <use visibility=local>
44 
45 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
46 // </reviewed>
47 
48 // <prerequisite>
49 //# Classes you should understand before using this one.
50 // <li> <linkto class=BaseTable>BaseTable</linkto>
51 // </prerequisite>
52 
53 // <etymology>
54 // NullTable represents a null table object, i.e. a Table object without
55 // an underlying table..
56 // </etymology>
57 
58 // <synopsis>
59 // Nullable is used to represent a null table.
60 // The default Table constructor used to a create a null pointer
61 // which results in core dumps when the Table object is actually used.
62 // The NullTable object makes it possible to catch such cases
63 // and throw an appropriate exception.
64 // </synopsis>
65 
66 
67 class NullTable : public BaseTable
68 {
69 public:
70  // Default constructor.
71  NullTable();
72 
73  virtual ~NullTable();
74 
75  // The table is a null table.
76  virtual Bool isNull() const;
77 
78  // All functions throw a "null table" exception.
79  // <group>
80  virtual void reopenRW();
81  virtual Bool asBigEndian() const;
82  virtual const StorageOption& storageOption() const;
83  virtual Bool isMultiUsed (Bool checkSubTable) const;
84  virtual const TableLock& lockOptions() const;
85  virtual void mergeLock (const TableLock& lockOptions);
86  virtual Bool hasLock (FileLocker::LockType) const;
87  virtual Bool lock (FileLocker::LockType, uInt nattempts);
88  virtual void unlock();
89  virtual void flush (Bool fsync, Bool recursive);
90  virtual void resync();
91  virtual uInt getModifyCounter() const;
92  virtual Bool isWritable() const;
93  virtual void deepCopy (const String& newName,
94  const Record& dataManagerInfo,
95  const StorageOption&,
96  int tableOption,
97  Bool valueCopy,
98  int endianFormat,
99  Bool noRows) const;
100  virtual TableDesc actualTableDesc() const;
101  virtual Record dataManagerInfo() const;
102  virtual TableRecord& keywordSet();
103  virtual TableRecord& rwKeywordSet();
104  virtual BaseColumn* getColumn (uInt columnIndex) const;
105  virtual BaseColumn* getColumn (const String& columnName) const;
106  virtual Bool canAddRow() const;
107  virtual void addRow (uInt nrrow, Bool initialize);
108  virtual Bool canRemoveRow() const;
109  virtual void removeRow (uInt rownr);
110  virtual DataManager* findDataManager (const String& name,
111  Bool byColumn) const;
112  virtual void addColumn (const ColumnDesc& columnDesc, Bool addToParent);
113  virtual void addColumn (const ColumnDesc& columnDesc,
114  const String& dataManager, Bool byName,
115  Bool addToParent);
116  virtual void addColumn (const ColumnDesc& columnDesc,
117  const DataManager& dataManager, Bool addToParent);
118  virtual void addColumn (const TableDesc& tableDesc,
119  const DataManager& dataManager, Bool addToParent);
120  virtual Bool canRemoveColumn (const Vector<String>& columnNames) const;
121  virtual void removeColumn (const Vector<String>& columnNames);
122  virtual Bool canRenameColumn (const String& columnName) const;
123  virtual void renameColumn (const String& newName, const String& oldName);
124  virtual void renameHypercolumn (const String& newName,
125  const String& oldName);
126  virtual Vector<uInt> rowNumbers() const;
127  virtual BaseTable* root();
128  virtual Bool rowOrder() const;
129  virtual Vector<uInt>* rowStorage();
130  virtual Bool adjustRownrs (uInt nrrow, Vector<uInt>& rownrs,
131  Bool determineOrder) const;
134  const Block<Int>& sortOrder,
135  int sortOption);
136  virtual void renameSubTables (const String& newName,
137  const String& oldName);
138  // </group>
139 
140 private:
141  // Copy constructor is forbidden, because copying a table requires
142  // some more knowledge (like table name of result).
143  // Declaring it private, makes it unusable.
144  NullTable (const NullTable&);
145 
146  // Assignment is forbidden, because copying a table requires
147  // some more knowledge (like table name of result).
148  // Declaring it private, makes it unusable.
149  NullTable& operator= (const NullTable&);
150 
151  // Throw an exception with the name of the function.
152  void throwError (const String& name) const;
153 };
154 
155 
156 
157 
158 } //# NAMESPACE CASACORE - END
159 
160 #endif
virtual BaseTable * doSort(PtrBlock< BaseColumn *> &, const Block< CountedPtr< BaseCompare > > &, const Block< Int > &sortOrder, int sortOption)
Do the actual sort.
virtual void reopenRW()
All functions throw a "null table" exception.
A 1-D Specialization of the Array class.
Definition: ArrayIO.h:45
virtual void renameColumn(const String &newName, const String &oldName)
Rename a column.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Try to lock the table for read or write access.
const TableDesc & tableDesc() const
Get the table description.
Definition: BaseTable.h:260
virtual Bool canRemoveColumn(const Vector< String > &columnNames) const
Test if columns can be removed.
virtual Vector< uInt > rowNumbers() const
Get a vector of row numbers.
virtual TableRecord & keywordSet()
Get readonly access to the table keyword set.
virtual void removeRow(uInt rownr)
Remove rows.
Class indicating a null Table object.
Definition: NullTable.h:67
virtual void unlock()
Unlock the table.
virtual BaseColumn * getColumn(uInt columnIndex) const
Get a column object using its index.
Envelope class for the description of a table column.
Definition: ColumnDesc.h:131
virtual void flush(Bool fsync, Bool recursive)
Flush the table, i.e.
virtual Bool hasLock(FileLocker::LockType) const
Has this process the read or write lock, thus can the table be read or written safely?
virtual Bool canRemoveRow() const
Test if it is possible to remove a row from this table.
virtual Bool canAddRow() const
Test if it is possible to add a row to this table.
virtual void resync()
Resync the Table object with the table file.
virtual const TableLock & lockOptions() const
Get the locking info.
int tableOption() const
Get the table option.
Definition: BaseTable.h:241
Options defining how table files are organized.
Definition: StorageOption.h:71
virtual BaseTable * root()
Get pointer to root table (i.e.
virtual void removeColumn(const Vector< String > &columnNames)
Remove columns.
virtual void renameSubTables(const String &newName, const String &oldName)
Rename the subtables (used by rename function).
NullTable()
Default constructor.
Referenced counted pointer for constant data.
Definition: CountedPtr.h:86
Abstract base class for tables.
Definition: BaseTable.h:99
virtual Bool asBigEndian() const
Is the table stored in big or little endian format?
virtual Vector< uInt > * rowStorage()
By the default the table cannot return the storage of rownrs.
virtual Bool canRenameColumn(const String &columnName) const
Test if a column can be renamed.
virtual void mergeLock(const TableLock &lockOptions)
Merge the given lock info with the existing one.
virtual uInt getModifyCounter() const
Get the modify counter.
virtual void addRow(uInt nrrow, Bool initialize)
Add one or more rows and possibly initialize them.
virtual DataManager * findDataManager(const String &name, Bool byColumn) const
Find the data manager with the given name or for the given column.
virtual void deepCopy(const String &newName, const Record &dataManagerInfo, const StorageOption &, int tableOption, Bool valueCopy, int endianFormat, Bool noRows) const
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void throwError(const String &name) const
Throw an exception with the name of the function.
Class to hold table lock options.
Definition: TableLock.h:65
A drop-in replacement for Block<T*>.
Definition: Block.h:861
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
virtual Bool isNull() const
The table is a null table.
simple 1-D array
Definition: ArrayIO.h:47
virtual Record dataManagerInfo() const
Get the data manager info.
virtual Bool isMultiUsed(Bool checkSubTable) const
Is the table in use (i.e.
virtual const StorageOption & storageOption() const
Get the storage option used for the table.
Abstract base class for a data manager.
Definition: DataManager.h:222
virtual TableDesc actualTableDesc() const
Get the actual table description.
virtual void renameHypercolumn(const String &newName, const String &oldName)
Rename a hypercolumn.
virtual Bool adjustRownrs(uInt nrrow, Vector< uInt > &rownrs, Bool determineOrder) const
Adjust the row numbers to be the actual row numbers in the root table.
virtual Bool isWritable() const
Test if this table is writable.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual Bool rowOrder() const
Tell if the table is in row order.
Define the structure of a Casacore table.
Definition: TableDesc.h:186
LockType
Define the possible lock types.
Definition: FileLocker.h:95
virtual void addColumn(const ColumnDesc &columnDesc, Bool addToParent)
Add one or more columns to the table.
NullTable & operator=(const NullTable &)
Assignment is forbidden, because copying a table requires some more knowledge (like table name of res...
this file contains all the compiler specific defines
Definition: mainpage.dox:28
virtual TableRecord & rwKeywordSet()
Get read/write access to the table keyword set.
unsigned int uInt
Definition: aipstype.h:51
Abstract base class for a table column.
Definition: BaseColumn.h:98