[810] | 1 | // |
---|
| 2 | // C++ Implementation: STTcal |
---|
| 3 | // |
---|
| 4 | // Description: |
---|
| 5 | // |
---|
| 6 | // |
---|
| 7 | // Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006 |
---|
| 8 | // |
---|
| 9 | // Copyright: See COPYING file that comes with this distribution |
---|
| 10 | // |
---|
| 11 | // |
---|
| 12 | #include <casa/Exceptions/Error.h> |
---|
| 13 | #include <tables/Tables/TableDesc.h> |
---|
| 14 | #include <tables/Tables/SetupNewTab.h> |
---|
| 15 | #include <tables/Tables/ScaColDesc.h> |
---|
| 16 | #include <tables/Tables/ArrColDesc.h> |
---|
| 17 | #include <tables/Tables/TableRecord.h> |
---|
| 18 | #include <tables/Tables/TableParse.h> |
---|
| 19 | #include <tables/Tables/TableRow.h> |
---|
| 20 | #include <casa/Containers/RecordField.h> |
---|
| 21 | |
---|
| 22 | #include "STTcal.h" |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | using namespace casa; |
---|
| 26 | |
---|
| 27 | namespace asap { |
---|
| 28 | |
---|
| 29 | const casa::String STTcal::name_ = "TCAL"; |
---|
| 30 | |
---|
| 31 | STTcal::STTcal(casa::Table::TableType tt) : |
---|
| 32 | STSubTable( name_, tt ) |
---|
| 33 | { |
---|
| 34 | setup(); |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | STTcal::~STTcal() |
---|
| 39 | { |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | void asap::STTcal::setup( ) |
---|
| 43 | { |
---|
| 44 | // add to base class table |
---|
| 45 | table_.addColumn(ScalarColumnDesc<String>("TIME")); |
---|
| 46 | table_.addColumn(ArrayColumnDesc<Float>("TCAL")); |
---|
| 47 | |
---|
| 48 | // new cached columns |
---|
| 49 | timeCol_.attach(table_,"TIME"); |
---|
| 50 | tcalCol_.attach(table_,"TCAL"); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | uInt STTcal::addEntry( const String& time, const Vector<Float>& cal) |
---|
| 54 | { |
---|
| 55 | // test if this already exists |
---|
| 56 | Table result = table_( table_.col("TIME") == time ); |
---|
| 57 | uInt resultid = 0; |
---|
| 58 | if ( result.nrow() > 0) { |
---|
| 59 | ROScalarColumn<uInt> c(result, "ID"); |
---|
| 60 | c.get(0, resultid); |
---|
| 61 | } else { |
---|
| 62 | uInt rno = table_.nrow(); |
---|
| 63 | table_.addRow(); |
---|
| 64 | // get last assigned tcal_id and increment |
---|
| 65 | if ( rno > 0 ) { |
---|
| 66 | idCol_.get(rno-1, resultid); |
---|
| 67 | resultid++; |
---|
| 68 | } |
---|
| 69 | tcalCol_.put(rno, cal); |
---|
| 70 | timeCol_.put(rno, time); |
---|
| 71 | idCol_.put(rno, resultid); |
---|
| 72 | } |
---|
| 73 | return resultid; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | } |
---|
| 77 | |
---|