1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
|
//# ForwardColRow.cc: Virtual Column Engine forwarding to another row/column
//# Copyright (C) 1995,1996,1997,2001
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: casa-feedback@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//# Includes
#include <casacore/tables/DataMan/ForwardColRow.h>
#include <casacore/tables/Tables/Table.h>
#include <casacore/tables/Tables/SetupNewTab.h>
#include <casacore/tables/Tables/TableColumn.h>
#include <casacore/tables/Tables/BaseColumn.h>
#include <casacore/tables/Tables/ColumnDesc.h>
#include <casacore/tables/DataMan/DataManError.h>
#include <casacore/tables/Tables/TableRecord.h>
#include <casacore/casa/Containers/Record.h>
namespace casacore { //# NAMESPACE CASACORE - BEGIN
ForwardColumnIndexedRowEngine::ForwardColumnIndexedRowEngine
(const String& dataManagerName,
const Record& spec)
: ForwardColumnEngine (dataManagerName, spec),
lastRow_p (-1)
{
setSuffix ("_Row");
if (spec.isDefined("COLUMNNAME")) {
spec.get ("COLUMNNAME", rowColumnName_p);
}
}
ForwardColumnIndexedRowEngine::ForwardColumnIndexedRowEngine
(const Table& referencedTable,
const String& rowColumnName,
const String& dataManagerName)
: ForwardColumnEngine (referencedTable, dataManagerName),
rowColumnName_p (rowColumnName),
lastRow_p (-1)
{
setSuffix ("_Row");
}
ForwardColumnIndexedRowEngine::ForwardColumnIndexedRowEngine
(const Table& referencedTable,
const String& rowColumnName)
: ForwardColumnEngine (referencedTable, ""),
rowColumnName_p (rowColumnName),
lastRow_p (-1)
{
setSuffix ("_Row");
}
ForwardColumnIndexedRowEngine::~ForwardColumnIndexedRowEngine()
{}
// Clone the engine object.
DataManager* ForwardColumnIndexedRowEngine::clone() const
{
DataManager* dmPtr = new ForwardColumnIndexedRowEngine (refTable(),
rowColumnName_p,
dataManagerName());
return dmPtr;
}
DataManagerColumn* ForwardColumnIndexedRowEngine::makeScalarColumn
(const String& name,
int dataType,
const String& dataTypeId)
{
ForwardColumnIndexedRow* colp = new ForwardColumnIndexedRow
(this, name, dataType,
dataTypeId, refTable());
addForwardColumn (colp);
return colp;
}
DataManagerColumn* ForwardColumnIndexedRowEngine::makeIndArrColumn
(const String& name,
int dataType,
const String& dataTypeId)
{
return makeScalarColumn (name, dataType, dataTypeId);
}
void ForwardColumnIndexedRowEngine::create64 (rownr_t)
{
// The table is new.
baseCreate();
// Define a keyword in the table telling the column containing the
// row numbers in the original table.
table().rwKeywordSet().define (keywordName ("_ForwardColumn_RowName"),
rowColumnName_p);
}
void ForwardColumnIndexedRowEngine::prepare()
{
basePrepare();
// Create the ScalarColumn object for the rownr column.
// Get its column name from the special table keyword defined in create.
const String& rowName = table().keywordSet().asString
(keywordName ("_ForwardColumn_RowName"));
rowColumn_p.attach (table(), rowName);
}
void ForwardColumnIndexedRowEngine::reopenRW()
{}
DataManager* ForwardColumnIndexedRowEngine::makeObject
(const String& dataManagerName,
const Record& spec)
{
DataManager* dmPtr = new ForwardColumnIndexedRowEngine (dataManagerName,
spec);
return dmPtr;
}
void ForwardColumnIndexedRowEngine::registerClass()
{
DataManager::registerCtor (className(), makeObject);
}
String ForwardColumnIndexedRowEngine::dataManagerType() const
{
return className();
}
String ForwardColumnIndexedRowEngine::className()
{
return "ForwardColumnIndexedRowEngine";
}
Record ForwardColumnIndexedRowEngine::dataManagerSpec() const
{
Record spec = ForwardColumnEngine::dataManagerSpec();
spec.define ("COLUMNNAME", rowColumnName_p);
return spec;
}
ForwardColumnIndexedRow::ForwardColumnIndexedRow
(ForwardColumnIndexedRowEngine* enginePtr,
const String& name,
int dataType,
const String& dataTypeId,
const Table& refTable)
: ForwardColumn (enginePtr, name, dataType, dataTypeId, refTable),
enginePtr_p (enginePtr)
{}
ForwardColumnIndexedRow::~ForwardColumnIndexedRow()
{}
void ForwardColumnIndexedRow::prepare (const Table& thisTable)
{
basePrepare (thisTable, False);
}
void ForwardColumnIndexedRow::setShape (rownr_t, const IPosition&)
{
throw (DataManInvOper
("setShape not supported by data manager ForwardColumnIndexedRow"));
}
uInt ForwardColumnIndexedRow::ndim (rownr_t rownr)
{ return colPtr()->ndim (convertRownr(rownr)); }
IPosition ForwardColumnIndexedRow::shape(rownr_t rownr)
{ return colPtr()->shape (convertRownr(rownr)); }
Bool ForwardColumnIndexedRow::isShapeDefined (rownr_t rownr)
{ return colPtr()->isDefined (convertRownr(rownr)); }
Bool ForwardColumnIndexedRow::canChangeShape() const
{
return False; // put is not supported
}
void ForwardColumnIndexedRow::getArrayV (rownr_t rownr, ArrayBase& dataPtr)
{ colPtr()->getArray (convertRownr(rownr), dataPtr); }
void ForwardColumnIndexedRow::getSliceV (rownr_t rownr, const Slicer& ns,
ArrayBase& dataPtr)
{ colPtr()->getSlice (convertRownr(rownr), ns, dataPtr); }
void ForwardColumnIndexedRow::putArrayV (rownr_t, const ArrayBase&)
{
throw (DataManInvOper
("putArray not supported by data manager ForwardColumnIndexedRow"));
}
void ForwardColumnIndexedRow::putSliceV (rownr_t, const Slicer&, const ArrayBase&)
{
throw (DataManInvOper
("putSlice not supported by data manager ForwardColumnIndexedRow"));
}
#define FORWARDCOLUMNINDEXEDROW_GETPUT(T,NM) \
void ForwardColumnIndexedRow::aips_name2(get,NM) (rownr_t rownr, T* dataPtr) \
{ colPtr()->get (convertRownr(rownr), dataPtr); } \
void ForwardColumnIndexedRow::aips_name2(put,NM) (rownr_t, const T*) \
{ \
throw (DataManInvOper \
("put not supported by data manager ForwardColumnIndexedRow")); \
}
FORWARDCOLUMNINDEXEDROW_GETPUT(Bool,Bool)
FORWARDCOLUMNINDEXEDROW_GETPUT(uChar,uChar)
FORWARDCOLUMNINDEXEDROW_GETPUT(Short,Short)
FORWARDCOLUMNINDEXEDROW_GETPUT(uShort,uShort)
FORWARDCOLUMNINDEXEDROW_GETPUT(Int,Int)
FORWARDCOLUMNINDEXEDROW_GETPUT(uInt,uInt)
FORWARDCOLUMNINDEXEDROW_GETPUT(Int64,Int64)
FORWARDCOLUMNINDEXEDROW_GETPUT(float,float)
FORWARDCOLUMNINDEXEDROW_GETPUT(double,double)
FORWARDCOLUMNINDEXEDROW_GETPUT(Complex,Complex)
FORWARDCOLUMNINDEXEDROW_GETPUT(DComplex,DComplex)
FORWARDCOLUMNINDEXEDROW_GETPUT(String,String)
FORWARDCOLUMNINDEXEDROW_GETPUT(void,Other)
} //# NAMESPACE CASACORE - END
|