source: trunk/src/SDMemTableWrapper.h@ 375

Last change on this file since 375 was 260, checked in by vor010, 20 years ago

SDMemTable & SDMemTableWrapper: formatSec and summary are now const functions.
Makefile has been updated to use the same version for both Narrabri and Epping

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1//#---------------------------------------------------------------------------
2//# SDMemTableWrapper.h: Wrapper classes to use CountedPtr
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2004
5//# ATNF
6//#
7//# This program is free software; you can redistribute it and/or modify it
8//# under the terms of the GNU General Public License as published by the Free
9//# Software Foundation; either version 2 of the License, or (at your option)
10//# any later version.
11//#
12//# This program is distributed in the hope that it will be useful, but
13//# WITHOUT ANY WARRANTY; without even the implied warranty of
14//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15//# Public License for more details.
16//#
17//# You should have received a copy of the GNU General Public License along
18//# with this program; if not, write to the Free Software Foundation, Inc.,
19//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20//#
21//# Correspondence concerning this software should be addressed as follows:
22//# Internet email: Malte.Marquarding@csiro.au
23//# Postal address: Malte Marquarding,
24//# Australia Telescope National Facility,
25//# P.O. Box 76,
26//# Epping, NSW, 2121,
27//# AUSTRALIA
28//#
29//# $Id:
30//#---------------------------------------------------------------------------
31#ifndef SDMEMTABLEWRAPPER_H
32#define SDMEMTABLEWRAPPER_H
33
34#include <vector>
35#include <string>
36
37#include "SDMemTable.h"
38
39namespace asap {
40
41class SDMemTableWrapper {
42
43public:
44 SDMemTableWrapper(const std::string& name) :
45 table_(new SDMemTable(name)) {;}
46 SDMemTableWrapper() :
47 table_(new SDMemTable()) {;}
48
49 SDMemTableWrapper(casa::CountedPtr<SDMemTable> cp) : table_(cp) {;}
50 //SDMemTableWrapper(SDMemTable* sdmt) : table_(sdmt) {;}
51 SDMemTableWrapper(const SDMemTableWrapper& mt) :
52 table_(mt.getCP()) {;}
53
54 SDMemTableWrapper(const SDMemTableWrapper& mt, const std::string& expr) :
55 table_(new SDMemTable(mt.getCP()->table(), expr)) {;}
56
57 SDMemTableWrapper copy() {
58 //CountedPtr<SDMemTable> cp = new SDMemTable(*this, False);
59 return SDMemTableWrapper(new SDMemTable(*(this->getCP()), casa::False));
60 }
61
62 SDMemTableWrapper getScan(int scan) {
63 casa::String cond("SELECT * from $1 WHERE SCANID == ");
64 cond += casa::String::toString(scan);
65 return SDMemTableWrapper(*this, cond);
66 }
67
68 SDMemTableWrapper getSource(const std::string& source) {
69 casa::String cond("SELECT * from $1 WHERE SRCNAME == pattern('");
70 cond += source;cond += "')";
71 return SDMemTableWrapper(*this, cond);
72 }
73
74 std::vector<float> getSpectrum(int whichRow=0) const {
75 return table_->getSpectrum(whichRow);
76 }
77
78 std::vector<double> getAbcissa(int whichRow=0) const {
79 return table_->getAbcissa(whichRow);
80 }
81 std::string getAbcissaString(int whichRow=0) const {
82 return table_->getAbcissaString(whichRow);
83 }
84
85 std::vector<float> getTsys() {
86 int nRow = table_->nRow();
87 std::vector<float> result(nRow);
88 for (uint i=0; i<nRow; i++) {
89 result[i] = table_->getTsys(i);
90 }
91 return result;
92 }
93
94 std::string getTime(int whichRow=0) {return table_->getTime(whichRow);}
95
96 std::string getFluxUnit() const {return table_->getFluxUnit();}
97 void setFluxUnit(const std::string& unit) {table_->setFluxUnit(unit);}
98
99 void setInstrument(const std::string& name) {table_->setInstrument(name);}
100
101 std::vector<bool> getMask(int whichRow=0) const {
102 return table_->getMask(whichRow);
103 }
104 bool setMask(const std::vector<int> mvals) const {
105 return table_->setMask(mvals);
106 }
107
108 void flag(int whichRow=-1) {
109 table_->flag(whichRow);
110 }
111 std::string getSourceName(int whichRow=0) {
112 return table_->getSourceName(whichRow);
113 }
114
115 void setSpectrum(std::vector<float> spectrum, int whichRow=0) {
116 table_->setSpectrum(spectrum, whichRow);
117 }
118
119 bool setIF(int whichIF=0) {return table_->setIF(whichIF);}
120 bool setBeam(int whichBeam=0) {return table_->setBeam(whichBeam);}
121 bool setPol(int whichPol=0) {return table_->setPol(whichPol);}
122
123 int getIF() {return table_->getIF();}
124 int getBeam() {return table_->getBeam();}
125 int getPol() {return table_->getPol();}
126
127 int nIF() {return table_->nIF();}
128 int nBeam() {return table_->nBeam();}
129 int nPol() {return table_->nPol();}
130 int nChan() {return table_->nChan();}
131 int nScan() {return table_->nScan();}
132 int nRow() {return table_->nRow();}
133
134 //sets the mask
135 bool setChannels(const std::vector<int>& whichChans) {
136 return setChannels(whichChans);
137 }
138 void makePersistent(const std::string& fname) {
139 table_->makePersistent(fname);
140 }
141
142 void setRestFreqs(std::vector<double> freqs, const std::string& theunit) {
143 table_->setRestFreqs(freqs, theunit);
144 }
145
146 std::vector<double> getRestFreqs() {
147 return table_->getRestFreqs();
148 }
149
150 void setCoordInfo(std::vector<string> theinfo) {
151 table_->setCoordInfo(theinfo);
152 }
153 std::vector<string> getCoordInfo() const {
154 return table_->getCoordInfo();
155 }
156
157 casa::CountedPtr<SDMemTable> getCP() const {return table_;}
158 SDMemTable* getPtr() {return &(*table_);}
159 std::string summary() const { return table_->summary(); }
160
161 std::vector<std::string> history(int whichRow=0) {
162 return table_->history(whichRow);
163 }
164
165private:
166 casa::CountedPtr<SDMemTable> table_;
167};
168
169} // namespace
170#endif
Note: See TracBrowser for help on using the repository browser.