[2] | 1 | //#---------------------------------------------------------------------------
|
---|
| 2 | //# SDMemTableWrapper.h: Wrapper classes to use CountedPtr
|
---|
| 3 | //#---------------------------------------------------------------------------
|
---|
| 4 | //# Copyright (C) 2004
|
---|
[125] | 5 | //# ATNF
|
---|
[2] | 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 | //#---------------------------------------------------------------------------
|
---|
[125] | 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:
|
---|
[90] | 44 | SDMemTableWrapper(const std::string& name) :
|
---|
[2] | 45 | table_(new SDMemTable(name)) {;}
|
---|
[90] | 46 | SDMemTableWrapper() :
|
---|
[18] | 47 | table_(new SDMemTable()) {;}
|
---|
[90] | 48 |
|
---|
[125] | 49 | SDMemTableWrapper(casa::CountedPtr<SDMemTable> cp) : table_(cp) {;}
|
---|
[90] | 50 | //SDMemTableWrapper(SDMemTable* sdmt) : table_(sdmt) {;}
|
---|
| 51 | SDMemTableWrapper(const SDMemTableWrapper& mt) :
|
---|
| 52 | table_(mt.getCP()) {;}
|
---|
| 53 |
|
---|
[80] | 54 | SDMemTableWrapper(const SDMemTableWrapper& mt, const std::string& expr) :
|
---|
| 55 | table_(new SDMemTable(mt.getCP()->table(), expr)) {;}
|
---|
[90] | 56 |
|
---|
| 57 | SDMemTableWrapper copy() {
|
---|
| 58 | //CountedPtr<SDMemTable> cp = new SDMemTable(*this, False);
|
---|
[125] | 59 | return SDMemTableWrapper(new SDMemTable(*(this->getCP()), casa::False));
|
---|
[90] | 60 | }
|
---|
| 61 |
|
---|
[2] | 62 | SDMemTableWrapper getScan(int scan) {
|
---|
[125] | 63 | casa::String cond("SELECT * from $1 WHERE SCANID == ");
|
---|
| 64 | cond += casa::String::toString(scan);
|
---|
[80] | 65 | return SDMemTableWrapper(*this, cond);
|
---|
[2] | 66 | }
|
---|
[80] | 67 |
|
---|
| 68 | SDMemTableWrapper getSource(const std::string& source) {
|
---|
[186] | 69 | casa::String cond("SELECT * from $1 WHERE SRCNAME == pattern('");
|
---|
| 70 | cond += source;cond += "')";
|
---|
[80] | 71 | return SDMemTableWrapper(*this, cond);
|
---|
| 72 | }
|
---|
| 73 |
|
---|
[51] | 74 | std::vector<float> getSpectrum(int whichRow=0) const {
|
---|
[2] | 75 | return table_->getSpectrum(whichRow);
|
---|
| 76 | }
|
---|
[41] | 77 |
|
---|
[158] | 78 | std::vector<double> getAbcissa(int whichRow=0) const {
|
---|
| 79 | return table_->getAbcissa(whichRow);
|
---|
[41] | 80 | }
|
---|
[158] | 81 | std::string getAbcissaString(int whichRow=0) const {
|
---|
| 82 | return table_->getAbcissaString(whichRow);
|
---|
[105] | 83 | }
|
---|
[41] | 84 |
|
---|
[157] | 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 |
|
---|
[51] | 94 | std::string getTime(int whichRow=0) {return table_->getTime(whichRow);}
|
---|
[2] | 95 |
|
---|
[207] | 96 | std::string getFluxUnit() const {return table_->getFluxUnit();}
|
---|
| 97 |
|
---|
[90] | 98 | std::vector<bool> getMask(int whichRow=0) const {
|
---|
| 99 | return table_->getMask(whichRow);
|
---|
[16] | 100 | }
|
---|
[90] | 101 | bool setMask(const std::vector<int> mvals) const {
|
---|
| 102 | return table_->setMask(mvals);
|
---|
| 103 | }
|
---|
[2] | 104 |
|
---|
[90] | 105 | void flag(int whichRow=-1) {
|
---|
| 106 | table_->flag(whichRow);
|
---|
| 107 | }
|
---|
[51] | 108 | std::string getSourceName(int whichRow=0) {
|
---|
[2] | 109 | return table_->getSourceName(whichRow);
|
---|
| 110 | }
|
---|
| 111 |
|
---|
[90] | 112 | void setSpectrum(std::vector<float> spectrum, int whichRow=0) {
|
---|
| 113 | table_->setSpectrum(spectrum, whichRow);
|
---|
| 114 | }
|
---|
| 115 |
|
---|
[2] | 116 | bool setIF(int whichIF=0) {return table_->setIF(whichIF);}
|
---|
| 117 | bool setBeam(int whichBeam=0) {return table_->setBeam(whichBeam);}
|
---|
[90] | 118 | bool setPol(int whichPol=0) {return table_->setPol(whichPol);}
|
---|
[2] | 119 |
|
---|
| 120 | int getIF() {return table_->getIF();}
|
---|
| 121 | int getBeam() {return table_->getBeam();}
|
---|
[90] | 122 | int getPol() {return table_->getPol();}
|
---|
[2] | 123 |
|
---|
[18] | 124 | int nIF() {return table_->nIF();}
|
---|
| 125 | int nBeam() {return table_->nBeam();}
|
---|
[90] | 126 | int nPol() {return table_->nPol();}
|
---|
| 127 | int nChan() {return table_->nChan();}
|
---|
| 128 | int nScan() {return table_->nScan();}
|
---|
| 129 | int nRow() {return table_->nRow();}
|
---|
[2] | 130 |
|
---|
| 131 | //sets the mask
|
---|
| 132 | bool setChannels(const std::vector<int>& whichChans) {
|
---|
[90] | 133 | return setChannels(whichChans);
|
---|
[2] | 134 | }
|
---|
| 135 | void makePersistent(const std::string& fname) {
|
---|
| 136 | table_->makePersistent(fname);
|
---|
| 137 | }
|
---|
[90] | 138 |
|
---|
| 139 | void setRestFreqs(std::vector<double> freqs, const std::string& theunit) {
|
---|
| 140 | table_->setRestFreqs(freqs, theunit);
|
---|
| 141 | }
|
---|
[105] | 142 | void setCoordInfo(std::vector<string> theinfo) {
|
---|
| 143 | table_->setCoordInfo(theinfo);
|
---|
| 144 | }
|
---|
| 145 | std::vector<string> getCoordInfo() const {
|
---|
| 146 | return table_->getCoordInfo();
|
---|
| 147 | }
|
---|
[90] | 148 |
|
---|
[125] | 149 | casa::CountedPtr<SDMemTable> getCP() const {return table_;}
|
---|
[138] | 150 | SDMemTable* getPtr() {return &(*table_);}
|
---|
[90] | 151 | std::string summary() { return table_->summary(); }
|
---|
[186] | 152 |
|
---|
[207] | 153 | std::vector<std::string> history(int whichRow=0) {
|
---|
| 154 | return table_->history(whichRow);
|
---|
| 155 | }
|
---|
| 156 |
|
---|
[2] | 157 | private:
|
---|
[125] | 158 | casa::CountedPtr<SDMemTable> table_;
|
---|
[2] | 159 | };
|
---|
| 160 |
|
---|
| 161 | } // namespace
|
---|
| 162 | #endif
|
---|