source: branches/asap-3.x/src/STHistory.cpp@ 2118

Last change on this file since 2118 was 860, checked in by mar637, 19 years ago

reworked history table
added STHistory class

File size: 1.9 KB
Line 
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
24using namespace casa;
25
26namespace asap {
27
28const casa::String STHistory::name_ = "HISTORY";
29
30STHistory::STHistory(const Scantable& parent ) :
31 STSubTable( parent, name_ )
32{
33 setup();
34}
35
36asap::STHistory::STHistory( casa::Table tab ) : STSubTable(tab, name_)
37{
38 itemCol_.attach(table_,"ITEM");
39}
40
41STHistory::~STHistory()
42{
43}
44
45STHistory& 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}
53void 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
62uInt 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
71void 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
80void 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
89std::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}
Note: See TracBrowser for help on using the repository browser.