- Timestamp:
- 02/28/06 10:49:29 (19 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STSelector.cpp
r842 r850 12 12 #include <tables/Tables/ExprNode.h> 13 13 #include <tables/Tables/TableParse.h> 14 #include <tables/Tables/ExprNode.h> 14 15 #include <casa/BasicSL/String.h> 15 16 #include <casa/iostream.h> 16 17 #include <casa/iomanip.h> 17 18 19 #include "MathUtils.h" 18 20 #include "STSelector.h" 19 21 … … 26 28 } 27 29 28 STSelector::STSelector( const STSelector & other ) : 29 selections_(other.selections_), 30 STSelector::STSelector( const STSelector& other ) : 31 intselections_(other.intselections_), 32 stringselections_(other.stringselections_), 30 33 taql_(other.taql_) { 31 34 } … … 34 37 { 35 38 if (&other != this) { 36 this->selections_ = other.selections_; 39 this->intselections_ = other.intselections_; 40 this->stringselections_ = other.stringselections_; 37 41 this->taql_ = other.taql_; 38 42 } … … 46 50 void STSelector::setScans( const std::vector< int >& scans ) 47 51 { 48 set ("SCANNO", scans);52 setint("SCANNO", scans); 49 53 } 50 54 51 55 void STSelector::setBeams( const std::vector< int >& beams ) 52 56 { 53 set ("BEAMNO", beams);57 setint("BEAMNO", beams); 54 58 } 55 59 56 60 void STSelector::setIFs( const std::vector< int >& ifs ) 57 61 { 58 set ("IFNO", ifs);62 setint("IFNO", ifs); 59 63 } 60 64 61 65 void STSelector::setPolarizations( const std::vector< int >& pols ) 62 66 { 63 set ("POLNO", pols);67 setint("POLNO", pols); 64 68 } 65 69 66 70 void asap::STSelector::setCycles( const std::vector< int >& cycs ) 67 71 { 68 set("CYCLENO", cycs); 69 } 70 71 void STSelector::set(const std::string& key, const std::vector< int >& val) 72 setint("CYCLENO", cycs); 73 } 74 75 void asap::STSelector::setName( const std::string& sname ) 76 { 77 std::string sql = "SELECT from $1 WHERE SRCNAME == pattern('"+sname+"')"; 78 setTaQL(sql); 79 } 80 81 void STSelector::setint(const std::string& key, const std::vector< int >& val) 72 82 { 73 83 if ( val.size() > 0 ) { 74 selections_[key] = val; 84 intselections_[key] = val; 85 } 86 } 87 88 void STSelector::setstring( const std::string& key, 89 const std::vector<std::string>& val ) 90 { 91 if ( val.size() > 0 ) { 92 stringselections_[key] = val; 75 93 } 76 94 } … … 87 105 } 88 106 TableExprNode query; 89 i dmap::const_iterator it =selections_.begin();90 for (it; it != selections_.end(); ++it) {107 intidmap::const_iterator it = intselections_.begin(); 108 for (it; it != intselections_.end(); ++it) { 91 109 TableExprNode theset(Vector<Int>( (*it).second )); 92 110 if ( query.isNull() ) { … … 96 114 } 97 115 } 116 stringidmap::const_iterator it1 = stringselections_.begin(); 117 for (it1; it1 != stringselections_.end(); ++it1) { 118 TableExprNode theset(mathutil::toVectorString( (*it1).second )); 119 if ( query.isNull() ) { 120 query = tab.col((*it1).first).in(theset); 121 } else { 122 query = tab.col((*it1).first).in(theset) && query; 123 } 124 } 98 125 // add taql query 99 126 if ( taql_.size() > 0 ) { … … 105 132 tmpt = tableCommand(taql_, tab); 106 133 } 107 return tmpt .copyToMemoryTable("dummy");134 return tmpt; 108 135 } else { 109 return tab(query) .copyToMemoryTable("dummy");110 } 111 } 112 113 std::vector< int > STSelector::get ( const std::string& key)114 { 115 if ( selections_.count(key) > 0) {116 return std::vector<int>();// selections_[key];136 return tab(query); 137 } 138 } 139 140 std::vector< int > STSelector::getint( const std::string& key ) 141 { 142 if (intselections_.count(key) > 0) { 143 return std::vector<int>();//intselections_[key]; 117 144 } 118 145 } … … 120 147 std::vector< int > STSelector::getScans( ) 121 148 { 122 return get ("SCANNO");149 return getint("SCANNO"); 123 150 } 124 151 125 152 std::vector< int > STSelector::getBeams( ) 126 153 { 127 return get ("BEAMNO");154 return getint("BEAMNO"); 128 155 } 129 156 130 157 std::vector< int > STSelector::getIFs( ) 131 158 { 132 return get ("IFNO");159 return getint("IFNO"); 133 160 } 134 161 135 162 std::vector< int > STSelector::getPols( ) 136 163 { 137 return get ("POLNO");164 return getint("POLNO"); 138 165 } 139 166 140 167 std::vector< int > asap::STSelector::getCycles( ) 141 168 { 142 return get ("CYCLENO");169 return getint("CYCLENO"); 143 170 } 144 171 … … 153 180 } 154 181 155 i dmap::const_iterator it =selections_.begin();156 while (it != selections_.end()) {157 if ( it != selections_.begin() )182 intidmap::const_iterator it = intselections_.begin(); 183 while (it != intselections_.end()) { 184 if ( it != intselections_.begin() ) 158 185 oss << setw(15) << " "; 159 186 oss << it->first << ": " << Vector<Int>(it->second); 160 187 ++it; 161 if ( it != selections_.end() ) oss << endl; 188 if ( it != intselections_.end() ) oss << endl; 189 } 190 stringidmap::const_iterator it1 = stringselections_.begin(); 191 while (it1 != stringselections_.end()) { 192 if ( it1 != stringselections_.begin() ) 193 oss << setw(15) << " "; 194 oss << it1->first << ": " << mathutil::toVectorString(it1->second); 195 ++it1; 196 if ( it1 != stringselections_.end() ) oss << endl; 162 197 } 163 198 if ( taql_.size() > 0 ) { … … 169 204 bool asap::STSelector::empty( ) const 170 205 { 171 return ( selections_.empty() && taql_.size() == 0 );172 } 206 return (intselections_.empty() && taql_.size() == 0 ); 207 } -
trunk/src/STSelector.h
r842 r850 41 41 void setPolarizations(const std::vector<int>& pols); 42 42 void setCycles(const std::vector<int>& cycs); 43 void setTaQL(const std::string& taql); 43 void setName(const std::string&); 44 virtual void setTaQL(const std::string& taql); 44 45 45 46 std::vector<int> getScans(); … … 52 53 casa::Table operator()(const casa::Table& tab) { return apply(tab); }; 53 54 54 void reset() { selections_.clear(); taql_ = "";};55 void reset() { intselections_.clear();stringselections_.clear(); taql_ = "";}; 55 56 56 57 bool empty() const; … … 58 59 std::string print(); 59 60 61 protected: 62 std::vector< int > getint( const std::string& key); 63 std::vector< std::string > getstring( const std::string& key); 64 65 void setint(const std::string& key, const std::vector< int >& val); 66 void setstring(const std::string& key, const std::vector< std::string >& val); 67 60 68 private: 61 // 62 std::vector< int > get( const std::string& key); 63 void set(const std::string& key, const std::vector< int >& val); 64 65 typedef std::map<std::string, std::vector<int> > idmap; 69 typedef std::map<std::string, std::vector<int> > intidmap; 70 typedef std::map<std::string, std::vector<std::string> > stringidmap; 66 71 // has to be mutable, as to stl limitations 67 mutable idmap selections_; 72 mutable intidmap intselections_; 73 mutable stringidmap stringselections_; 68 74 std::string taql_; 69 75 };
Note:
See TracChangeset
for help on using the changeset viewer.