1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 ***************************************************************************/
16 #ifndef PREDICATE_IMPL_H
17 #define PREDICATE_IMPL_H
23 class PredicateImpl
:public Predicate
25 //Members set during initialization of the term
26 char fldName1
[IDENTIFIER_LENGTH
];
27 char fldName2
[IDENTIFIER_LENGTH
];
35 //Members set during execution
36 void *tuple
; //pointer to the tuple
38 //This will be set before calling evaluate
44 strcpy(fldName1
, ""); strcpy(fldName2
, "");
45 operand
= NULL
; operandPtr
= NULL
; lhs
= rhs
= NULL
;
46 tuple
= NULL
; table
= NULL
;
50 void setTerm(const char* fName1
, ComparisionOp op
, const char *fName2
);
52 //Operand should be of the same type of the field.This is must
53 void setTerm(const char* fName1
, ComparisionOp op
, void *opnd
);
55 void setTerm(const char* fName1
, ComparisionOp op
, void **opnd
);
58 void setTerm(Predicate
*p1
, LogicalOp op
, Predicate
*p2
= NULL
);
60 void* valPtrForIndexField(const char *name
);
62 DbRetVal
evaluate(bool &result
);
64 void setTable(Table
*tbl
);
65 void setTuple(void *tpl
);
67 bool isNotOrInvolved();
68 //check predicate, whether it has field name and == operator
69 //and does not have OR, NOT operator
70 // TODO:: expression like !(f1 !=100) wont be optimized for now
71 bool pointLookupInvolved(const char *fName
);