[2] | 1 | //#--------------------------------------------------------------------------- |
---|
| 2 | //# SDMemTableWrapper.h: Wrapper classes to use CountedPtr |
---|
| 3 | //#--------------------------------------------------------------------------- |
---|
| 4 | //# Copyright (C) 2004 |
---|
| 5 | //# Malte Marquarding, 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 | //#--------------------------------------------------------------------------- |
---|
[80] | 31 | #ifndef _SDMEMTABLEWRAPPER_H |
---|
| 32 | #define _SDMEMTABLEWRAPPER_H |
---|
[2] | 33 | |
---|
| 34 | #include <vector> |
---|
| 35 | #include <string> |
---|
| 36 | |
---|
| 37 | #include "SDMemTable.h" |
---|
| 38 | |
---|
[83] | 39 | namespace asap { |
---|
[2] | 40 | |
---|
| 41 | class SDMemTableWrapper { |
---|
| 42 | |
---|
| 43 | public: |
---|
[18] | 44 | SDMemTableWrapper(const std::string& name) : |
---|
[2] | 45 | table_(new SDMemTable(name)) {;} |
---|
[18] | 46 | SDMemTableWrapper() : |
---|
| 47 | table_(new SDMemTable()) {;} |
---|
| 48 | |
---|
[2] | 49 | SDMemTableWrapper(CountedPtr<SDMemTable> cp) : table_(cp) {;} |
---|
| 50 | SDMemTableWrapper(SDMemTable* sdmt) : table_(sdmt) {;} |
---|
| 51 | |
---|
[80] | 52 | SDMemTableWrapper(const SDMemTableWrapper& mt, const std::string& expr) : |
---|
| 53 | table_(new SDMemTable(mt.getCP()->table(), expr)) {;} |
---|
[2] | 54 | |
---|
| 55 | SDMemTableWrapper getScan(int scan) { |
---|
[80] | 56 | String cond("SELECT * from $1 WHERE SCANID == "); |
---|
| 57 | cond += String::toString(scan); |
---|
| 58 | return SDMemTableWrapper(*this, cond); |
---|
[2] | 59 | } |
---|
[80] | 60 | |
---|
| 61 | SDMemTableWrapper getSource(const std::string& source) { |
---|
| 62 | String cond("SELECT * from $1 WHERE SRCNAME == '"); |
---|
| 63 | cond += source;cond += "'"; |
---|
| 64 | return SDMemTableWrapper(*this, cond); |
---|
| 65 | } |
---|
| 66 | |
---|
[51] | 67 | std::vector<float> getSpectrum(int whichRow=0) const { |
---|
[2] | 68 | return table_->getSpectrum(whichRow); |
---|
| 69 | } |
---|
[41] | 70 | |
---|
| 71 | std::vector<double> getAbscissa(int whichRow, |
---|
| 72 | const std::string& unit = "GHz", |
---|
[79] | 73 | const std::string& frame = "TOPO", |
---|
[41] | 74 | double restfreq=0.0) const { |
---|
[79] | 75 | return table_->getAbscissa(whichRow,unit,frame,restfreq); |
---|
[41] | 76 | } |
---|
| 77 | |
---|
[51] | 78 | float getTsys(int whichRow=0) {return table_->getTsys(whichRow);} |
---|
| 79 | std::string getTime(int whichRow=0) {return table_->getTime(whichRow);} |
---|
[2] | 80 | |
---|
[51] | 81 | std::vector<bool> getMask(int whichRow=0) const { |
---|
[16] | 82 | return table_->getMask(whichRow); |
---|
| 83 | } |
---|
| 84 | bool setMask(const std::vector<int> mvals) const { |
---|
| 85 | return table_->setMask(mvals); |
---|
[51] | 86 | } |
---|
[2] | 87 | |
---|
[51] | 88 | std::string getSourceName(int whichRow=0) { |
---|
[2] | 89 | return table_->getSourceName(whichRow); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | bool setIF(int whichIF=0) {return table_->setIF(whichIF);} |
---|
| 93 | bool setBeam(int whichBeam=0) {return table_->setBeam(whichBeam);} |
---|
| 94 | bool setPol(int whichPol=0) {return table_->setPol(whichPol);} |
---|
| 95 | |
---|
| 96 | int getIF() {return table_->getIF();} |
---|
| 97 | int getBeam() {return table_->getBeam();} |
---|
| 98 | int getPol() {return table_->getPol();} |
---|
| 99 | |
---|
[18] | 100 | int nIF() {return table_->nIF();} |
---|
| 101 | int nBeam() {return table_->nBeam();} |
---|
| 102 | int nPol() {return table_->nPol();} |
---|
| 103 | int nChan() {return table_->nChan();} |
---|
[51] | 104 | int nScans() {return table_->nScans();} |
---|
[2] | 105 | |
---|
| 106 | //sets the mask |
---|
| 107 | bool setChannels(const std::vector<int>& whichChans) { |
---|
| 108 | return setChannels(whichChans); |
---|
| 109 | } |
---|
| 110 | void makePersistent(const std::string& fname) { |
---|
| 111 | table_->makePersistent(fname); |
---|
| 112 | } |
---|
| 113 | CountedPtr<SDMemTable> getCP() const {return table_;} |
---|
| 114 | void summary() { table_->summary(); } |
---|
| 115 | |
---|
| 116 | private: |
---|
| 117 | CountedPtr<SDMemTable> table_; |
---|
| 118 | }; |
---|
| 119 | |
---|
| 120 | } // namespace |
---|
| 121 | #endif |
---|