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