Changeset 847 for trunk/src/SDMemTableWrapper.h
- Timestamp:
- 02/24/06 10:03:21 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMemTableWrapper.h
r794 r847 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 1 // 2 // C++ Interface: Scantable 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 #ifndef ASAPSCANTABLEWRAPPER_H 13 #define ASAPSCANTABLEWRAPPER_H 33 14 34 15 #include <vector> … … 38 19 #include "MathUtils.h" 39 20 #include "SDFitTable.h" 40 #include "S DMemTable.h"21 #include "Scantable.h" 41 22 42 23 namespace asap { 43 44 class SDMemTableWrapper { 24 /** 25 * This class contains and wraps a CountedPtr<Scantable>, as the CountedPtr 26 * class does not provide the dor operator which is need for references 27 * in boost::python 28 * see Scantable for interfce description 29 * 30 * @brief The main ASAP data container wrapper 31 * @author Malte Marquarding 32 * @date 2006-02-23 33 * @version 2.0a 34 */ 35 class ScantableWrapper { 45 36 46 37 public: 47 SDMemTableWrapper(const std::string& name) : 48 table_(new SDMemTable(name)) {;} 49 SDMemTableWrapper() : 50 table_(new SDMemTable()) {;} 51 52 SDMemTableWrapper(casa::CountedPtr<SDMemTable> cp) : table_(cp) {;} 53 //SDMemTableWrapper(SDMemTable* sdmt) : table_(sdmt) {;} 54 SDMemTableWrapper(const SDMemTableWrapper& mt) : 38 ScantableWrapper(const std::string& name) : 39 table_(new Scantable(name)) {;} 40 41 ScantableWrapper() : 42 table_(new Scantable()) {;} 43 44 ScantableWrapper(casa::CountedPtr<Scantable> cp) : table_(cp) {;} 45 46 ScantableWrapper(const ScantableWrapper& mt) : 55 47 table_(mt.getCP()) {;} 56 48 57 SDMemTableWrapper(const SDMemTableWrapper& mt, const std::string& expr) : 58 table_(new SDMemTable(mt.getCP()->table(), expr)) {;} 59 60 SDMemTableWrapper copy() { 61 //CountedPtr<SDMemTable> cp = new SDMemTable(*this, False); 62 return SDMemTableWrapper(new SDMemTable(*(this->getCP()), casa::False)); 63 } 64 65 SDMemTableWrapper getScan(std::vector<int> scan) { 66 casa::String cond("SELECT FROM $1 WHERE SCANID IN "); 67 casa::Vector<casa::Int> v(scan); 68 casa::ostringstream oss; 69 oss << v; 70 cond += casa::String(oss); 71 return SDMemTableWrapper(*this, cond); 72 } 73 74 SDMemTableWrapper getSource(const std::string& source) { 75 casa::String cond("SELECT * from $1 WHERE SRCNAME == pattern('"); 76 cond += source;cond += "')"; 77 return SDMemTableWrapper(*this, cond); 78 } 79 80 SDMemTableWrapper getSQL(const std::string& sqlexpr) { 81 return SDMemTableWrapper(*this, sqlexpr); 82 } 49 ScantableWrapper(const ScantableWrapper& mt, const std::string& expr) : 50 table_(new Scantable(mt.getCP()->table(), expr)) {;} 51 52 ScantableWrapper copy() { 53 return ScantableWrapper(new Scantable(*(this->getCP()), false)); 54 } 55 83 56 84 57 std::vector<float> getSpectrum(int whichRow=0) const { … … 148 121 } 149 122 150 void setSpectrum(std::vector<float> spectrum, int whichRow=0) { 151 table_->setSpectrum(spectrum, whichRow); 152 } 153 154 bool setIF(int whichIF=0) {return table_->setIF(whichIF);} 155 bool setBeam(int whichBeam=0) {return table_->setBeam(whichBeam);} 156 bool setPol(int whichPol=0) {return table_->setPol(whichPol);} 157 158 int getIF() {return table_->getIF();} 159 int getBeam() {return table_->getBeam();} 160 int getPol() {return table_->getPol();} 161 162 int nIF() {return table_->nIF();} 163 int nBeam() {return table_->nBeam();} 164 int nPol() {return table_->nPol();} 165 int nChan() {return table_->nChan();} 166 int nScan() {return table_->nScan();} 167 int nRow() {return table_->nRow();} 168 int nStokes() {return table_->nStokes();} 169 170 //sets the mask 171 bool setChannels(const std::vector<int>& whichChans) { 172 return setChannels(whichChans); 173 } 123 void setSpectrum(std::vector<float> spectrum, int whichrow=0) { 124 table_->setSpectrum(spectrum, whichrow); 125 } 126 127 int getIF(int whichrow) {return table_->getIF(whichrow);} 128 int getBeam(int whichrow) {return table_->getBeam(whichrow);} 129 int getPol(int whichrow) {return table_->getPol(whichrow);} 130 131 STSelector getSelection() { return table_->getSelection(); } 132 133 int nif(int scanno=-1) {return table_->nif(scanno);} 134 int nbeam(int scanno=-1) {return table_->nbeam(scanno);} 135 int npol(int scanno=-1) {return table_->npol(scanno);} 136 int nchan(int ifno=-1) {return table_->nchan(ifno);} 137 int nscan() {return table_->nscan();} 138 int nrow() {return table_->nrow();} 139 ///@todo int nstokes() {return table_->nStokes();} 140 174 141 void makePersistent(const std::string& fname) { 175 142 table_->makePersistent(fname); 176 143 } 177 144 178 bool setRestFreqs(const std::vector<double>& restfreqs, 179 const std::string& unit, 180 const std::vector<std::string>& lines, 181 const std::string& source, int whichIF) { 182 casa::Vector<casa::Double> restFreqs2(restfreqs); 183 return table_->setRestFreqs(restFreqs2, casa::String(unit), 184 lines, casa::String(source), 185 casa::Int(whichIF)); 186 } 187 188 std::string spectralLines() const {return table_->spectralLines();} 189 190 std::vector<double> getRestFreqs() { 191 return table_->getRestFreqs(); 145 void setRestFreqs(double rf, const std::string& unit) { 146 table_->setRestFreqs(rf, unit); 147 } 148 149 void setRestFreqs(const std::string& name) { 150 table_->setRestFreqs(name); 151 } 152 153 std::vector<double> getRestFrequencies() { 154 return table_->getRestFrequencies(); 192 155 } 193 156 … … 199 162 } 200 163 201 casa::CountedPtr<S DMemTable> getCP() const {return table_;}202 S DMemTable* getPtr() {return &(*table_);}164 casa::CountedPtr<Scantable> getCP() const {return table_;} 165 Scantable* getPtr() {return &(*table_);} 203 166 204 167 std::string summary(bool verbose=false) const { … … 230 193 231 194 private: 232 casa::CountedPtr<S DMemTable> table_;195 casa::CountedPtr<Scantable> table_; 233 196 }; 234 197
Note: See TracChangeset
for help on using the changeset viewer.