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 #include <casacore/casa/Containers/Block.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  ~MSMBase();
86 
87  // Clone this object.
88  // It does not clone MSMColumn objects possibly used.
89  DataManager* clone() const;
90 
91  // Get the type name of the data manager (i.e. MemoryStMan).
92  String dataManagerType() const;
93 
94  // Get the name given to this storage manager.
95  String dataManagerName() const;
96 
97  // Get the nr of rows in this storage manager.
98  uInt nrow() const
99  { return nrrow_p; }
100 
101  // Does the storage manager allow to add rows? (yes)
102  Bool canAddRow() const;
103 
104  // Does the storage manager allow to delete rows? (yes)
105  Bool canRemoveRow() const;
106 
107  // Does the storage manager allow to add columns? (yes)
108  Bool canAddColumn() const;
109 
110  // Does the storage manager allow to delete columns? (yes)
111  Bool canRemoveColumn() const;
112 
113  // Make the object from the string.
114  // This function gets registered in the DataManager "constructor" map.
116  const Record& spec);
117 
118 
119 private:
120  // Flush and optionally fsync the data.
121  // It does not done anything and always returns a False status.
122  virtual Bool flush (AipsIO&, Bool fsync);
123 
124  // Let the storage manager create the nr of rows needed.
125  virtual void create (uInt nrrow);
126 
127  // Open the storage manager file for an existing table.
128  // It fills the rows with 0 values.
129  virtual void open (uInt nrrow, AipsIO&);
130 
131  // Let the data manager initialize itself further.
132  // It creates nr of rows (given to create) if needed.
133  // Note this is done after reallocateColumn.
134  virtual void prepare();
135 
136  // Resync the storage manager with the new file contents.
137  // It adds or removes rows as needed.
138  // It cannot know which rows are deleted, so it always deletes
139  // the last rows.
140  virtual void resync (uInt nrrow);
141 
142  // The data manager will be deleted (because all its columns are
143  // requested to be deleted).
144  // It does not have to do anything.
145  virtual void deleteManager();
146 
147  // Add rows to all columns.
148  void addRow (uInt nrrow);
149 
150  // Delete a row from all columns.
151  void removeRow (uInt rownr);
152 
153  // Create a column in the storage manager on behalf of a table column.
154  // <group>
155  // Create a scalar column.
156  DataManagerColumn* makeScalarColumn (const String& name, int dataType,
157  const String& dataTypeID);
158  // Create a direct array column.
159  DataManagerColumn* makeDirArrColumn (const String& name, int dataType,
160  const String& dataTypeID);
161  // Create an indirect array column.
162  DataManagerColumn* makeIndArrColumn (const String& name, int dataType,
163  const String& dataTypeID);
164  // </group>
165 
166  // The MemoryStMan wants to do reallocateColumn.
167  Bool canReallocateColumns() const;
168 
169  // Reallocate the column object if it is part of this data manager.
170  // It returns a pointer to the new column object.
171  // It is used to replace an MSMIndColumn object for indirect array with
172  // a fixed shape by an MSMDirColumn object.
174 
175  // Add a column.
177 
178  // Delete a column.
180 
181 
182  // Name given by user to this storage manager.
184  // The number of rows in the columns.
186  // The number of rows in create().
188  // The assembly of all columns.
190 };
191 
192 
193 
194 
195 } //# NAMESPACE CASACORE - END
196 
197 #endif
casacore::AipsIO
AipsIO is the object persistency mechanism of Casacore
Definition: AipsIO.h:168
casacore::DataManager
Abstract base class for a data manager.
Definition: DataManager.h:224
casacore::PtrBlock
A drop-in replacement for Block<T*>.
Definition: Block.h:814
casacore::MSMBase::makeScalarColumn
DataManagerColumn * makeScalarColumn(const String &name, int dataType, const String &dataTypeID)
Create a column in the storage manager on behalf of a table column.
casacore::MSMBase::addColumn
void addColumn(DataManagerColumn *)
Add a column.
casacore::MSMBase::create
virtual void create(uInt nrrow)
Let the storage manager create the nr of rows needed.
casacore::DataManagerColumn
Abstract base class for a column in a data manager.
Definition: DataManager.h:611
casacore::MSMBase::MSMBase
MSMBase()
Create a memory storage manager.
casacore::MSMBase::deleteManager
virtual void deleteManager()
The data manager will be deleted (because all its columns are requested to be deleted).
casacore::MSMBase::canAddColumn
Bool canAddColumn() const
Does the storage manager allow to add columns? (yes)
casacore::MSMBase::makeDirArrColumn
DataManagerColumn * makeDirArrColumn(const String &name, int dataType, const String &dataTypeID)
Create a direct array column.
casacore::MSMBase::resync
virtual void resync(uInt nrrow)
Resync the storage manager with the new file contents.
casacore::MSMBase::~MSMBase
~MSMBase()
casacore::uInt
unsigned int uInt
Definition: aipstype.h:51
casacore::MSMBase::removeRow
void removeRow(uInt rownr)
Delete a row from all columns.
casacore::MSMBase::makeIndArrColumn
DataManagerColumn * makeIndArrColumn(const String &name, int dataType, const String &dataTypeID)
Create an indirect array column.
casacore::MSMBase::nrow
uInt nrow() const
Get the nr of rows in this storage manager.
Definition: MSMBase.h:98
casacore::MSMBase::prepare
virtual void prepare()
Let the data manager initialize itself further.
casacore::MSMBase::removeColumn
void removeColumn(DataManagerColumn *)
Delete a column.
casacore::MSMBase
Base class for memory-based table storage manager class.
Definition: MSMBase.h:67
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::MSMBase::canReallocateColumns
Bool canReallocateColumns() const
The MemoryStMan wants to do reallocateColumn.
casacore::MSMBase::open
virtual void open(uInt nrrow, AipsIO &)
Open the storage manager file for an existing table.
casacore::MSMBase::dataManagerType
String dataManagerType() const
Get the type name of the data manager (i.e.
casacore::MSMBase::nrrow_p
uInt nrrow_p
The number of rows in the columns.
Definition: MSMBase.h:185
casacore::MSMBase::makeObject
static DataManager * makeObject(const String &dataManagerType, const Record &spec)
Make the object from the string.
casacore::MSMBase::stmanName_p
String stmanName_p
Name given by user to this storage manager.
Definition: MSMBase.h:183
casacore::MSMBase::nrrowCreate_p
uInt nrrowCreate_p
The number of rows in create().
Definition: MSMBase.h:187
casacore::MSMBase::canRemoveRow
Bool canRemoveRow() const
Does the storage manager allow to delete rows? (yes)
casacore::MSMBase::dataManagerName
String dataManagerName() const
Get the name given to this storage manager.
casacore::String
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::MSMBase::canAddRow
Bool canAddRow() const
Does the storage manager allow to add rows? (yes)
casacore::MSMBase::flush
virtual Bool flush(AipsIO &, Bool fsync)
Flush and optionally fsync the data.
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::MSMBase::addRow
void addRow(uInt nrrow)
Add rows to all columns.
casacore::Record
A hierarchical collection of named fields of various types.
Definition: Record.h:180
casacore::MSMBase::reallocateColumn
DataManagerColumn * reallocateColumn(DataManagerColumn *column)
Reallocate the column object if it is part of this data manager.
casacore::MSMBase::clone
DataManager * clone() const
Clone this object.
casacore::MSMBase::colSet_p
PtrBlock< MSMColumn * > colSet_p
The assembly of all columns.
Definition: MSMBase.h:189
casacore::MSMBase::canRemoveColumn
Bool canRemoveColumn() const
Does the storage manager allow to delete columns? (yes)