| 1 | //
|
|---|
| 2 | // C++ Implementation: STHistory
|
|---|
| 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/TableParse.h>
|
|---|
| 17 | #include <tables/Tables/TableRow.h>
|
|---|
| 18 | #include <tables/Tables/TableCopy.h>
|
|---|
| 19 |
|
|---|
| 20 | #include "STDefs.h"
|
|---|
| 21 | #include "STHistory.h"
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | using namespace casa;
|
|---|
| 25 |
|
|---|
| 26 | namespace asap {
|
|---|
| 27 |
|
|---|
| 28 | const casa::String STHistory::name_ = "HISTORY";
|
|---|
| 29 |
|
|---|
| 30 | STHistory::STHistory(const Scantable& parent ) :
|
|---|
| 31 | STSubTable( parent, name_ )
|
|---|
| 32 | {
|
|---|
| 33 | setup();
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | asap::STHistory::STHistory( casa::Table tab ) : STSubTable(tab, name_)
|
|---|
| 37 | {
|
|---|
| 38 | itemCol_.attach(table_,"ITEM");
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | STHistory::~STHistory()
|
|---|
| 42 | {
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | STHistory& asap::STHistory::operator =( const STHistory & other )
|
|---|
| 46 | {
|
|---|
| 47 | if (this != &other) {
|
|---|
| 48 | static_cast<STSubTable&>(*this) = other;
|
|---|
| 49 | itemCol_.attach(table_,"ITEM");
|
|---|
| 50 | }
|
|---|
| 51 | return *this;
|
|---|
| 52 | }
|
|---|
| 53 | void asap::STHistory::setup( )
|
|---|
| 54 | {
|
|---|
| 55 | // add to base class table
|
|---|
| 56 | table_.addColumn(ScalarColumnDesc<String>("ITEM"));
|
|---|
| 57 |
|
|---|
| 58 | // new cached columns
|
|---|
| 59 | itemCol_.attach(table_,"ITEM");
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | uInt STHistory::addEntry( const String& item)
|
|---|
| 63 | {
|
|---|
| 64 | uInt rno = table_.nrow();
|
|---|
| 65 | table_.addRow();
|
|---|
| 66 | itemCol_.put(rno, item);
|
|---|
| 67 | idCol_.put(rno, 0);
|
|---|
| 68 | return 0;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | void asap::STHistory::getEntry( String& item, uInt id)
|
|---|
| 72 | {
|
|---|
| 73 | Table t = table_(table_.col("ID") == Int(id) );
|
|---|
| 74 | if (t.nrow() == 0 ) {
|
|---|
| 75 | throw(AipsError("STHistory::getEntry - id out of range"));
|
|---|
| 76 | }
|
|---|
| 77 | item = "";
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | void asap::STHistory::append( const STHistory & other )
|
|---|
| 81 | {
|
|---|
| 82 | const Table& t = other.table();
|
|---|
| 83 | addEntry(asap::SEPERATOR);
|
|---|
| 84 | TableCopy::copyRows(table_, t, table_.nrow(), 0, t.nrow());
|
|---|
| 85 | addEntry(asap::SEPERATOR);
|
|---|
| 86 |
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | std::vector<std::string> asap::STHistory::getHistory( ) const
|
|---|
| 90 | {
|
|---|
| 91 | std::vector<std::string> stlout;
|
|---|
| 92 | for (uInt i=0; i<table_.nrow(); ++i) {
|
|---|
| 93 | stlout.push_back(itemCol_(i));
|
|---|
| 94 | }
|
|---|
| 95 | return stlout;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | }
|
|---|