source: trunk/src/Accelerator.h@ 3091

Last change on this file since 3091 was 3084, checked in by Takeshi Nakazato, 9 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes/No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...


Get rid of warnings from table module that warns the change of the location of some header files.

File size: 1.9 KB
RevLine 
[2458]1#ifndef ASAPACCELERATOR_H
2#define ASAPACCELERATOR_H
3//
4// C++ Interface: CustomTableExprNode
5//
6// Description:
7// Various utilities for speed.
8//
9// Author: Kohji Nakamura <k.nakamura@nao.ac.jp>, (C) 2012
10//
11// Copyright: See COPYING file that comes with this distribution
12//
13//
14
[2470]15#include <casa/Utilities/Assert.h>
[3084]16#include <tables/TaQL/ExprNode.h>
[2458]17#include <tables/Tables/ScalarColumn.h>
18
19namespace asap {
20
21using namespace casa;
22
[2470]23class TableExprPredicate {
24public:
25 virtual ~TableExprPredicate() {}
26 virtual Bool match(Table const& table, const TableExprId& id) = 0;
27};
28
[2458]29class CustomTableExprNodeRep :public TableExprNodeRep {
[2470]30 TableExprPredicate & pred_;
[2458]31public:
[2470]32 CustomTableExprNodeRep(const Table &table,
33 TableExprPredicate & pred)
[2458]34 :TableExprNodeRep(TableExprNodeRep::NTBool,
35 TableExprNodeRep::VTScalar,
36 TableExprNodeRep::OtUndef,
[2470]37 table),
38 pred_(pred) {}
39 virtual ~CustomTableExprNodeRep() {}
40 virtual Bool getBool(const TableExprId& id) {
41 return pred_.match(table(), id);
42 }
[2458]43};
44
45class CustomTableExprNode: public TableExprNode {
46public:
[2470]47 CustomTableExprNode(CustomTableExprNodeRep &nodeRep)
48 : TableExprNode(&nodeRep) {
[2458]49 }
50 virtual ~CustomTableExprNode() {
51 }
52};
53
54template<typename T, size_t N>
55class SingleTypeEqPredicate: public TableExprPredicate {
56 Table const & table;
57 ROScalarColumn<T> *cols[N];
58 T const *values;
59public:
60 SingleTypeEqPredicate(Table const &table_,
61 char const*const colNames[],
62 T const values_[]):
63 table(table_), values(values_) {
64 for (size_t i = 0; i < N; i++) {
65 cols[i] = new ROScalarColumn<T>(table, colNames[i]);
66 }
67 }
68 virtual ~SingleTypeEqPredicate() {
69 for (size_t i = 0; i < N; i++) {
70 delete cols[i];
71 }
72 }
[2470]73 virtual Bool match(Table const& table, const TableExprId& id) {
74 DebugAssert(&table == &this->table, AipsError);
[3069]75 (void)table;
[2458]76 for (size_t i = 0; i < N; i++) {
77 T v;
78 cols[i]->get(id.rownr(), v);
79 if (v != values[i]) {
80 return false;
81 }
82 }
83 return true;
84 }
85};
86
87} // asap
88
89#endif // ASAPACCELERATOR_H
Note: See TracBrowser for help on using the repository browser.