forked from Uradouby/cs660-pa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPredicate.h
More file actions
69 lines (61 loc) · 1.82 KB
/
Copy pathPredicate.h
File metadata and controls
69 lines (61 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef DB_PREDICATE_H
#define DB_PREDICATE_H
#include <string>
#include <db/Tuple.h>
#include <db/Field.h>
#include <cassert>
namespace db {
/**
* Predicate compares tuples to a specified Field value.
*/
class Predicate {
/** Constants used for return codes in Field.compare */
int field;
Op op;
const Field *operand;
public:
/**
* Constructor.
*
* @param field
* field number of passed in tuples to compare against.
* @param op
* operation to use for comparison
* @param operand
* field value to compare passed in tuples to
*/
Predicate(int field, Op op, const Field *operand);
/**
* @return the field number
*/
int getField() const;
/**
* @return the operator
*/
Op getOp() const;
/**
* @return the operand
*/
const Field *getOperand() const;
/**
* Compares the field number of t specified in the constructor to the
* operand field specified in the constructor using the operator specific in
* the constructor. The comparison can be made through Field's compare
* method.
*
* @param t
* The tuple to compare against
* @return true if the comparison is true, false otherwise.
*/
bool filter(const Tuple &t) const;
/**
* Returns something useful, like "f = field_id op = op_string operand =
* operand_string
*/
std::string toString() const {
return "f = " + std::to_string(getField()) + " op = " + to_string(getOp()) +
" operand = " + getOperand()->to_string();
}
};
}
#endif