Changeset 2470
- Timestamp:
- 04/18/12 15:19:39 (13 years ago)
- Location:
- branches/hpc33/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/hpc33/src/Accelerator.h
r2458 r2470 13 13 // 14 14 15 #include <casa/Utilities/Assert.h> 15 16 #include <tables/Tables/ExprNode.h> 16 17 #include <tables/Tables/ScalarColumn.h> … … 20 21 using namespace casa; 21 22 23 class TableExprPredicate { 24 public: 25 virtual ~TableExprPredicate() {} 26 virtual Bool match(Table const& table, const TableExprId& id) = 0; 27 }; 28 22 29 class CustomTableExprNodeRep :public TableExprNodeRep { 30 TableExprPredicate & pred_; 23 31 public: 24 CustomTableExprNodeRep(const Table &table) 32 CustomTableExprNodeRep(const Table &table, 33 TableExprPredicate & pred) 25 34 :TableExprNodeRep(TableExprNodeRep::NTBool, 26 35 TableExprNodeRep::VTScalar, 27 36 TableExprNodeRep::OtUndef, 28 table) {} 29 }; 30 31 class TableExprPredicate { 32 public: 33 virtual ~TableExprPredicate() {} 34 virtual Bool match(Table const& table, const TableExprId& id) const = 0; 37 table), 38 pred_(pred) {} 39 virtual ~CustomTableExprNodeRep() {} 40 virtual Bool getBool(const TableExprId& id) { 41 return pred_.match(table(), id); 42 } 35 43 }; 36 44 37 45 class CustomTableExprNode: public TableExprNode { 38 CustomTableExprNodeRep const nodeRep;39 TableExprPredicate const & pred_;40 46 public: 41 CustomTableExprNode( Table const &table, TableExprPredicate const &pred)42 : TableExprNode( ), nodeRep(table), pred_(pred) {47 CustomTableExprNode(CustomTableExprNodeRep &nodeRep) 48 : TableExprNode(&nodeRep) { 43 49 } 44 50 virtual ~CustomTableExprNode() { 45 }46 const TableExprNodeRep* getNodeRep() const {47 return &nodeRep;48 }49 void get(const TableExprId& id, Bool& value) const {50 value = pred_.match(nodeRep.table(), id);51 51 } 52 52 }; … … 71 71 } 72 72 } 73 virtual Bool match(Table const& table, const TableExprId& id) const { 73 virtual Bool match(Table const& table, const TableExprId& id) { 74 DebugAssert(&table == &this->table, AipsError); 74 75 for (size_t i = 0; i < N; i++) { 75 76 T v; -
branches/hpc33/src/STMath.cpp
r2460 r2470 221 221 uInt const values1[] = { rec.asuInt("IFNO"), rec.asuInt("BEAMNO"), rec.asuInt("POLNO") }; 222 222 SingleTypeEqPredicate<uInt, 3> myPred(tin, colNames1, values1); 223 CustomTableExprNode myExpr(tin, myPred); 223 CustomTableExprNodeRep myNodeRep(tin, myPred); 224 myNodeRep.link(); // to avoid automatic delete when myExpr is destructed. 225 CustomTableExprNode myExpr(myNodeRep); 224 226 Table basesubt = tin(myExpr); 227 cout << "CustomTableExprNode selected row number is " << basesubt.nrow() << "/" << tin.nrow() << endl; 225 228 #else 226 229 Table basesubt = tin( tin.col("BEAMNO") == Int(rec.asuInt("BEAMNO"))
Note:
See TracChangeset
for help on using the changeset viewer.