casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSMBase.h
Go to the documentation of this file.
1 //# MSMBase.h: Base class for storage manager for tables using memory
2 //# Copyright (C) 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: MSMBase.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
27 
28 #ifndef TABLES_MSMBASE_H
29 #define TABLES_MSMBASE_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 class MSMColumn;
41 
42 
43 // <summary>
44 // Base class for memory-based table storage manager class
45 // </summary>
46 
47 // <use visibility=local>
48 
49 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
50 // </reviewed>
51 
52 // <prerequisite>
53 //# Classes you should understand before using this one.
54 // <li> <linkto class=DataManager>DataManager</linkto>
55 // </prerequisite>
56 
57 // <etymology>
58 // MSMBase is the base class for MemoryStMan.
59 // </etymology>
60 
61 // <synopsis>
62 // See class <linkto class=MemoryStMan>MemoryStMan</linkto> for
63 // the description.
64 // </synopsis>
65 
66 
67 class MSMBase : public DataManager
68 {
69 public:
70 
71  // Create a memory storage manager.
72  // Its name will be blank.
73  MSMBase();
74 
75  // Create a memory storage manager with the given name.
76  // Its name can be used later in e.g. Table::addColumn to
77  // add a column to this storage manager.
78  // <br> Note that the 2nd constructor is needed for table creation
79  // from a record specification.
80  // <group>
81  MSMBase (const String& storageManagerName);
82  MSMBase (const String& storageManagerName, const Record&);
83  // </group>
84 
85  virtual ~MSMBase();
86 
87  // Clone this object.
88  // It does not clone MSMColumn objects possibly used.
89  virtual DataManager* clone() const;
90 
91  // Get the type name of the data manager (i.e. MemoryStMan).
92  virtual String dataManagerType() const;
93 
94  // Get the name given to this storage manager.
95  virtual String dataManagerName() const;
96 
97  // Set the hasPut_p flag. In this way the StManAipsIOColumn objects
98  // can indicate that data have been put.
99  void setHasPut()
100  { hasPut_p = True; }
101 
102  // Get the nr of rows in this storage manager.
103  rownr_t nrow() const
104  { return nrrow_p; }
105 
106  // Does the storage manager allow to add rows? (yes)
107  virtual Bool canAddRow() const;
108 
109  // Does the storage manager allow to delete rows? (yes)
110  virtual Bool canRemoveRow() const;
111 
112  // Does the storage manager allow to add columns? (yes)
113  virtual Bool canAddColumn() const;
114 
115  // Does the storage manager allow to delete columns? (yes)
116  virtual Bool canRemoveColumn() const;
117 
118  // Make the object from the string.
119  // This function gets registered in the DataManager "constructor" map.
120  static DataManager* makeObject (const String& dataManagerType,
121  const Record& spec);
122 
123 
124 private:
125  // Flush and optionally fsync the data.
126  // It does not done anything and always returns a False status.
127  virtual Bool flush (AipsIO&, Bool fsync);
128 
129  // Let the storage manager create the nr of rows needed.
130  virtual void create64 (rownr_t nrrow);
131 
132  // Open the storage manager file for an existing table.
133  // It fills the rows with 0 values.
134  virtual rownr_t open64 (rownr_t nrrow, AipsIO&);
135 
136  // Let the data manager initialize itself further.
137  // It creates nr of rows (given to create) if needed.
138  // Note this is done after reallocateColumn.
139  virtual void prepare();
140 
141  // Resync the storage manager with the new file contents.
142  // It adds or removes rows as needed.
143  // It cannot know which rows are deleted, so it always deletes
144  // the last rows.
145  virtual rownr_t resync64 (rownr_t nrrow);
146 
147  // The data manager will be deleted (because all its columns are
148  // requested to be deleted).
149  // It does not have to do anything.
150  virtual void deleteManager();
151 
152  // Add rows to all columns.
153  virtual void addRow64 (rownr_t nrrow);
154 
155  // Delete a row from all columns.
156  virtual void removeRow64 (rownr_t rownr);
157 
158  // Create a column in the storage manager on behalf of a table column.
159  // <group>
160  // Create a scalar column.
161  virtual DataManagerColumn* makeScalarColumn (const String& name, int dataType,
162  const String& dataTypeID);
163  // Create a direct array column.
164  virtual DataManagerColumn* makeDirArrColumn (const String& name, int dataType,
165  const String& dataTypeID);
166  // Create an indirect array column.
167  virtual DataManagerColumn* makeIndArrColumn (const String& name, int dataType,
168  const String& dataTypeID);
169  // </group>
170 
171  // The MemoryStMan wants to do reallocateColumn.
172  virtual Bool canReallocateColumns() const;
173 
174  // Reallocate the column object if it is part of this data manager.
175  // It returns a pointer to the new column object.
176  // It is used to replace an MSMIndColumn object for indirect array with
177  // a fixed shape by an MSMDirColumn object.
179 
180  // Add a column.
181  virtual void addColumn (DataManagerColumn*);
182 
183  // Delete a column.
184  virtual void removeColumn (DataManagerColumn*);
185 
186 protected:
187  // Name given by user to this storage manager.
189  // The number of rows in the columns.
191  // The number of rows in create().
193  // The assembly of all columns.
195  // Has anything been put since the last flush?
197 };
198 
199 
200 } //# NAMESPACE CASACORE - END
201 
202 #endif
static DataManager * makeObject(const String &dataManagerType, const Record &spec)
Make the object from the string.
String stmanName_p
Name given by user to this storage manager.
Definition: MSMBase.h:188
virtual ~MSMBase()
virtual Bool canRemoveColumn() const
Does the storage manager allow to delete columns? (yes)
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
Abstract base class for a column in a data manager.
Bool hasPut_p
Has anything been put since the last flush?
Definition: MSMBase.h:196
void setHasPut()
Set the hasPut_p flag.
Definition: MSMBase.h:99
Base class for memory-based table storage manager class.
Definition: MSMBase.h:67
virtual void prepare()
Let the data manager initialize itself further.
virtual void addRow64(rownr_t nrrow)
Add rows to all columns.
virtual DataManagerColumn * makeDirArrColumn(const String &name, int dataType, const String &dataTypeID)
Create a direct array column.
PtrBlock< MSMColumn * > colSet_p
The assembly of all columns.
Definition: MSMBase.h:194
virtual Bool canRemoveRow() const
Does the storage manager allow to delete rows? (yes)
virtual Bool canAddColumn() const
Does the storage manager allow to add columns? (yes)
virtual rownr_t open64(rownr_t nrrow, AipsIO &)
Open the storage manager file for an existing table.
virtual DataManager * clone() const
Clone this object.
virtual Bool flush(AipsIO &, Bool fsync)
Flush and optionally fsync the data.
virtual DataManagerColumn * reallocateColumn(DataManagerColumn *column)
Reallocate the column object if it is part of this data manager.
rownr_t nrow() const
Get the nr of rows in this storage manager.
Definition: MSMBase.h:103
virtual rownr_t resync64(rownr_t nrrow)
Resync the storage manager with the new file contents.
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
virtual void removeColumn(DataManagerColumn *)
Delete a column.
virtual void removeRow64(rownr_t rownr)
Delete a row from all columns.
virtual DataManagerColumn * makeScalarColumn(const String &name, int dataType, const String &dataTypeID)
Create a column in the storage manager on behalf of a table column.
A drop-in replacement for Block&lt;T*&gt;.
Definition: Block.h:814
rownr_t nrrowCreate_p
The number of rows in create().
Definition: MSMBase.h:192
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
virtual String dataManagerType() const
Get the type name of the data manager (i.e.
rownr_t nrrow_p
The number of rows in the columns.
Definition: MSMBase.h:190
Abstract base class for a data manager.
Definition: DataManager.h:220
virtual void deleteManager()
The data manager will be deleted (because all its columns are requested to be deleted).
String: the storage and methods of handling collections of characters.
Definition: String.h:225
virtual void addColumn(DataManagerColumn *)
Add a column.
virtual Bool canReallocateColumns() const
The MemoryStMan wants to do reallocateColumn.
virtual DataManagerColumn * makeIndArrColumn(const String &name, int dataType, const String &dataTypeID)
Create an indirect array column.
virtual void create64(rownr_t nrrow)
Let the storage manager create the nr of rows needed.
virtual String dataManagerName() const
Get the name given to this storage manager.
const Bool True
Definition: aipstype.h:43
virtual Bool canAddRow() const
Does the storage manager allow to add rows? (yes)
MSMBase()
Create a memory storage manager.