include/PredicateImpl.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by www.databasecache.com                           *
00003  *   Contact: praba_tuty@databasecache.com                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015   ***************************************************************************/
00016 #ifndef PREDICATE_IMPL_H
00017 #define PREDICATE_IMPL_H
00018 #include<DataType.h>
00019 #include<Predicate.h>
00020 #include<ErrorType.h>
00021 class TableImpl;
00022 class Table;
00023 class PredicateImpl:public Predicate
00024 {
00025     //Members set during initialization of the term
00026     char fldName1[IDENTIFIER_LENGTH];
00027     char fldName2[IDENTIFIER_LENGTH];
00028     ComparisionOp compOp;
00029     void *operand;
00030     void **operandPtr;
00031     LogicalOp logicalOp;
00032     PredicateImpl *lhs;
00033     PredicateImpl *rhs;
00034 
00035     //Members set during execution
00036     void *tuple; //pointer to the tuple
00037 
00038     //This will be set before calling evaluate
00039     TableImpl *table;
00040 
00041     public:
00042     PredicateImpl()
00043     {
00044         strcpy(fldName1, ""); strcpy(fldName2, ""); 
00045         operand = NULL; operandPtr = NULL; lhs = rhs = NULL; 
00046         tuple = NULL; table = NULL; 
00047     }
00048     ~PredicateImpl(){}
00049 
00050     void setTerm(const char* fName1, ComparisionOp op, const char *fName2);
00051 
00052     //Operand should be of the same type of the field.This is must
00053     void setTerm(const char* fName1, ComparisionOp op, void *opnd);
00054 
00055     void setTerm(const char* fName1, ComparisionOp op, void **opnd);
00056 
00057 
00058     void setTerm(Predicate *p1, LogicalOp op, Predicate *p2 = NULL);
00059 
00060     void* valPtrForIndexField(const char *name);
00061 
00062     DbRetVal evaluate(bool &result);
00063 
00064     void setTable(Table *tbl);
00065     void setTuple(void *tpl);
00066     bool isSingleTerm();
00067     bool isNotOrInvolved();
00068     //check predicate, whether it has field name and == operator
00069     //and does not have OR, NOT operator
00070     // TODO:: expression like !(f1 !=100) wont be optimized for now
00071     bool pointLookupInvolved(const char *fName);
00072 
00073    void print();
00074 
00075 };
00076 
00077 #endif

Generated on Mon Jun 9 22:37:14 2008 for csql by  doxygen 1.4.7