- Timestamp:
- 04/06/12 14:55:14 (13 years ago)
- Location:
- branches/hpc33/src
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/hpc33/src/STMath.cpp
r2449 r2458 53 53 #include "STMath.h" 54 54 #include "STSelector.h" 55 #include "Accelerator.h" 55 56 56 57 using namespace casa; 57 58 using namespace asap; 58 59 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 };120 60 121 61 // 2012/02/17 TN … … 280 220 static char const*const colNames1[] = { "BEAMNO", "IFNO", "POLNO" }; 281 221 uInt const values1[] = { rec.asuInt("BEAMNO"), rec.asuInt("IFNO"), rec.asuInt("POLNO") }; 282 MyPredicate<uInt, 3> myPred(tin, colNames1, values1);222 SingleTypeEqPredicate<uInt, 3> myPred(tin, colNames1, values1); 283 223 CustomTableExprNode myExpr(tin, myPred); 284 224 Table basesubt = tin(myExpr);
Note:
See TracChangeset
for help on using the changeset viewer.