casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlainColumn.h
Go to the documentation of this file.
1 //# PlainColumn.h: Base class for a column in a plain table
2 //# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001
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_PLAINCOLUMN_H
29 #define TABLES_PLAINCOLUMN_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
38 
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41 //# Forward Declarations
42 class TableAttr;
43 class BaseColumnDesc;
44 class DataManager;
45 class DataManagerColumn;
46 class AipsIO;
47 class IPosition;
48 
49 
50 // <summary>
51 // Base class for a column in a plain table
52 // </summary>
53 
54 // <use visibility=local>
55 
56 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
57 // </reviewed>
58 
59 // <prerequisite>
60 //# Classes you should understand before using this one.
61 // <li> BaseColumn
62 // <li> PlainTable
63 // </prerequisite>
64 
65 // <etymology>
66 // PlainColumn represents any column in a plain table.
67 // A plain table is a regular table, i.e. not a table like a
68 // RefTable which is a view on a plain table.
69 // </etymology>
70 
71 // <synopsis>
72 // Abstract base class for all types of columns in a plain table.
73 // It implements the common functionality for all columns in a plain
74 // table. Furthermore it defines some virtual functions (on top of
75 // the virtual functions defined in BaseColumn) which are specific for
76 // plain columns.
77 // </synopsis>
78 
79 // <todo asof="$DATE:$">
80 //# A List of bugs, limitations, extensions or planned refinements.
81 // </todo>
82 
83 
84 class PlainColumn : public BaseColumn
85 {
86 public:
87 
89 
90  virtual ~PlainColumn();
91 
92  // Test if the column is in principle writable.
93  // This does not test if the table itself is writable.
94  // That has to be done by the caller.
95  virtual Bool isWritable() const;
96 
97  // Test if the column is stored (otherwise it is virtual).
98  virtual Bool isStored() const;
99 
100  // Get access to the column keyword set.
101  // <group>
104  // </group>
105 
106  // Get nr of rows in the column.
107  rownr_t nrow() const;
108 
109  // Define the shape of all arrays in the column.
110  virtual void setShapeColumn (const IPosition& shape);
111 
112  // Test if the column is bound to a storage manager or
113  // virtual column engine.
114  virtual Bool isBound() const;
115 
116  // Bind the column to a data manager.
117  virtual void bind (DataManager*);
118 
119  // Create a data manager column for a filled column.
120  virtual void createDataManagerColumn() = 0;
121 
122  // Get the pointer to the data manager.
123  DataManager* dataManager() const;
124 
125  // Get the pointer to the data manager column.
127 
128  // Get a pointer to the underlying column cache.
129  virtual ColumnCache& columnCache();
130 
131  // Set the maximum cache size (in bytes) to be used by a storage manager.
132  virtual void setMaximumCacheSize (uInt nbytes);
133 
134  // Write the column.
135  void putFile (AipsIO&, const TableAttr&);
136 
137  // Read the column.
138  void getFile (AipsIO&, const ColumnSet&, const TableAttr&);
139 
140 protected:
141  DataManager* dataManPtr_p; //# Pointer to data manager.
142  DataManagerColumn* dataColPtr_p; //# Pointer to column in data manager.
144  String originalName_p; //# Column name before any rename
145  Bool rtraceColumn_p; //# trace reads of the column?
146  Bool wtraceColumn_p; //# trace writes of the column?
147 
148  // Get the trace-id of the table.
149  int traceId() const
150  { return colSetPtr_p->traceId(); }
151 
152  // Write the column.
153  // The control information is written into the given AipsIO object,
154  // while the data is written by the storage manager.
155  virtual void putFileDerived (AipsIO&) = 0;
156 
157  // Read the column back.
158  // The control information is read from the given AipsIO object.
159  // This is used to bind the column to the appropriate data manager.
160  virtual void getFileDerived (AipsIO&, const ColumnSet&) = 0;
161 
162  // Check the length of a value.
163  // This a meant for String values for which a maximum length is defined.
164  // The void* version is a no-op for other values.
165  // <group>
166  void checkValueLength (const void*) const;
167  void checkValueLength (const String* value) const;
168  void checkValueLength (const Array<String>* value) const;
169  // </group>
170 
171  // Lock the table before reading or writing.
172  // If manual or permanent locking is in effect, it checks if
173  // the table is locked.
174  // <group>
175  void checkReadLock (Bool wait) const;
176  void checkWriteLock (Bool wait) const;
177  // </group>
178 
179  // Inspect the auto lock when the inspection interval has expired and
180  // release it when another process needs the lock.
181  void autoReleaseLock() const;
182 };
183 
184 
186  { return dataManPtr_p; }
188  { return dataColPtr_p; }
189 
190 inline void PlainColumn::checkValueLength (const void*) const
191  {}
192 
193 inline void PlainColumn::checkReadLock (Bool wait) const
194  { colSetPtr_p->checkReadLock (wait); }
195 inline void PlainColumn::checkWriteLock (Bool wait) const
196  { colSetPtr_p->checkWriteLock (wait); }
197 inline void PlainColumn::autoReleaseLock() const
199 
200 
201 
202 } //# NAMESPACE CASACORE - END
203 
204 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
int traceId() const
Get the trace-id of the table.
Definition: PlainColumn.h:149
void checkReadLock(Bool wait)
Check if the table is locked for read or write.
Definition: ColumnSet.h:347
void checkReadLock(Bool wait) const
Lock the table before reading or writing.
Definition: PlainColumn.h:193
void autoReleaseLock() const
Inspect the auto lock when the inspection interval has expired and release it when another process ne...
Definition: PlainColumn.h:197
virtual void putFileDerived(AipsIO &)=0
Write the column.
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
virtual void setMaximumCacheSize(uInt nbytes)
Set the maximum cache size (in bytes) to be used by a storage manager.
Abstract base class for a column in a data manager.
An abstract base class for table column descriptions.
Definition: BaseColDesc.h:107
DataManagerColumn *& dataManagerColumn()
Get the pointer to the data manager column.
Definition: PlainColumn.h:187
void putFile(AipsIO &, const TableAttr &)
Write the column.
ColumnSet * colSetPtr_p
Definition: PlainColumn.h:143
Class to manage a set of table columns.
Definition: ColumnSet.h:93
int traceId() const
Get the trace-id of the table.
Definition: ColumnSet.h:213
virtual void getFileDerived(AipsIO &, const ColumnSet &)=0
Read the column back.
DataManagerColumn * dataColPtr_p
Definition: PlainColumn.h:142
virtual Bool isStored() const
Test if the column is stored (otherwise it is virtual).
void autoReleaseLock()
Inspect the auto lock when the inspection interval has expired and release it when another process ne...
Definition: ColumnSet.h:366
virtual void createDataManagerColumn()=0
Create a data manager column for a filled column.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
PlainColumn(const BaseColumnDesc *, ColumnSet *)
A caching object for a table column.
Definition: ColumnCache.h:86
DataManager * dataManager() const
Get the pointer to the data manager.
Definition: PlainColumn.h:185
virtual Bool isWritable() const
Test if the column is in principle writable.
void checkWriteLock(Bool wait) const
Definition: PlainColumn.h:195
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:185
A templated N-D Array class with zero origin. Array&lt;T, Alloc&gt; is a templated, N-dimensional, Array class. The origin is zero, but by default indices are zero-based. This Array class is the base class for the Vector, Matrix, and Cube subclasses.
Definition: Array.h:156
void checkValueLength(const void *) const
Check the length of a value.
Definition: PlainColumn.h:190
Base class for a column in a plain table.
Definition: PlainColumn.h:84
void checkWriteLock(Bool wait)
Definition: ColumnSet.h:354
virtual IPosition shape(rownr_t rownr) const
Get the shape of an array in a particular cell.
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
virtual ColumnCache & columnCache()
Get a pointer to the underlying column cache.
void getFile(AipsIO &, const ColumnSet &, const TableAttr &)
Read the column.
Abstract base class for a data manager.
Definition: DataManager.h:220
rownr_t nrow() const
Get nr of rows in the column.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
TableRecord & rwKeywordSet()
Get access to the column keyword set.
virtual void bind(DataManager *)
Bind the column to a data manager.
Some attributes of a table.
Definition: TableAttr.h:77
virtual void setShapeColumn(const IPosition &shape)
Define the shape of all arrays in the column.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
TableRecord & keywordSet()
unsigned int uInt
Definition: aipstype.h:51
virtual Bool isBound() const
Test if the column is bound to a storage manager or virtual column engine.
DataManager * dataManPtr_p
Definition: PlainColumn.h:141
Abstract base class for a table column.
Definition: BaseColumn.h:98