Changeset 2470 for branches


Ignore:
Timestamp:
04/18/12 15:19:39 (12 years ago)
Author:
KohjiNakamura
Message:

bug fix

Location:
branches/hpc33/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/hpc33/src/Accelerator.h

    r2458 r2470  
    1313//
    1414
     15#include <casa/Utilities/Assert.h>
    1516#include <tables/Tables/ExprNode.h>
    1617#include <tables/Tables/ScalarColumn.h>
     
    2021using namespace casa;
    2122
     23class TableExprPredicate {
     24public:
     25        virtual ~TableExprPredicate() {}
     26        virtual Bool match(Table const& table, const TableExprId& id) = 0;
     27};
     28
    2229class CustomTableExprNodeRep :public TableExprNodeRep {
     30        TableExprPredicate & pred_;
    2331public:
    24         CustomTableExprNodeRep(const Table &table)
     32        CustomTableExprNodeRep(const Table &table,
     33                TableExprPredicate & pred)
    2534        :TableExprNodeRep(TableExprNodeRep::NTBool,
    2635                TableExprNodeRep::VTScalar,
    2736                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        }
    3543};
    3644
    3745class CustomTableExprNode: public TableExprNode {
    38         CustomTableExprNodeRep const nodeRep;
    39         TableExprPredicate const & pred_;
    4046public:
    41         CustomTableExprNode(Table const &table, TableExprPredicate const &pred)
    42         : TableExprNode(), nodeRep(table), pred_(pred) {
     47        CustomTableExprNode(CustomTableExprNodeRep &nodeRep)
     48        : TableExprNode(&nodeRep) {
    4349        }
    4450        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);
    5151        }
    5252};
     
    7171                }
    7272        }
    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);
    7475                for (size_t i = 0; i < N; i++) {
    7576                        T v;
  • branches/hpc33/src/STMath.cpp

    r2460 r2470  
    221221      uInt const values1[] = { rec.asuInt("IFNO"), rec.asuInt("BEAMNO"), rec.asuInt("POLNO") };
    222222      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);
    224226      Table basesubt = tin(myExpr);
     227cout << "CustomTableExprNode selected row number is " << basesubt.nrow() << "/" << tin.nrow() << endl;
    225228#else
    226229      Table basesubt = tin( tin.col("BEAMNO") == Int(rec.asuInt("BEAMNO"))
Note: See TracChangeset for help on using the changeset viewer.