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