Changeset 2449
- Timestamp:
- 03/29/12 19:43:29 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/hpc33/src/STMath.cpp
r2443 r2449 56 56 using namespace casa; 57 57 using namespace asap; 58 59 class TableExprPredicate { 60 public: 61 virtual ~TableExprPredicate() {} 62 virtual Bool match(Table const& table, const TableExprId& id) const = 0; 63 }; 64 65 class CustomTableExprNodeRep :public TableExprNodeRep { 66 TableExprPredicate const & pred_; 67 public: 68 CustomTableExprNodeRep(const Table &table, 69 TableExprPredicate const & pred) 70 :TableExprNodeRep(TableExprNodeRep::NTBool, 71 TableExprNodeRep::VTScalar, 72 TableExprNodeRep::OtUndef, 73 table), 74 pred_(pred) {} 75 virtual Bool getBool(const TableExprId& id) { 76 return pred_.match(table(), id); 77 } 78 }; 79 80 class CustomTableExprNode: public TableExprNode { 81 CustomTableExprNodeRep nodeRep; 82 public: 83 CustomTableExprNode(Table const &table, TableExprPredicate const &pred) 84 : nodeRep(table, pred), TableExprNode(&nodeRep) { 85 } 86 virtual ~CustomTableExprNode() { 87 } 88 }; 89 90 template<typename T, size_t N> 91 class MyPredicate: public TableExprPredicate { 92 Table const & table; 93 ROScalarColumn<T> *cols[N]; 94 uInt const *values; 95 public: 96 virtual ~MyPredicate() { 97 for (size_t i = 0; i < N; i++) { 98 delete cols[i]; 99 } 100 } 101 MyPredicate(Table const &table_, 102 char const*const colNames[], 103 uInt const values_[]): 104 table(table_), values(values_) { 105 for (size_t i = 0; i < N; i++) { 106 cols[i] = new ROScalarColumn<T>(table, colNames[i]); 107 } 108 } 109 virtual Bool match(Table const& table, const TableExprId& id) const { 110 for (size_t i = 0; i < N; i++) { 111 T v; 112 cols[i]->get(id.rownr(), v); 113 if (v != values[i]) { 114 return false; 115 } 116 } 117 return true; 118 } 119 }; 58 120 59 121 // 2012/02/17 TN … … 214 276 ROScalarColumn<Double> tmp(tin, "TIME"); 215 277 Double td;tmp.get(0,td); 278 279 #if 1 280 static char const*const colNames1[] = { "BEAMNO", "IFNO", "POLNO" }; 281 uInt const values1[] = { rec.asuInt("BEAMNO"), rec.asuInt("IFNO"), rec.asuInt("POLNO") }; 282 MyPredicate<uInt, 3> myPred(tin, colNames1, values1); 283 CustomTableExprNode myExpr(tin, myPred); 284 Table basesubt = tin(myExpr); 285 #else 216 286 Table basesubt = tin( tin.col("BEAMNO") == Int(rec.asuInt("BEAMNO")) 217 287 && tin.col("IFNO") == Int(rec.asuInt("IFNO")) 218 288 && tin.col("POLNO") == Int(rec.asuInt("POLNO")) ); 289 #endif 219 290 Table subt; 220 291 if ( avmode == "SOURCE") {
Note:
See TracChangeset
for help on using the changeset viewer.