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