Condition Class Reference

Represents the condition part of SQL Query. More...

#include <Predicate.h>

Collaboration diagram for Condition:

Collaboration graph
[legend]

Public Member Functions

 Condition ()
 ~Condition ()
void reset ()
PredicategetPredicate ()
 gets the current predicate.
void setPredicate (Predicate *predicate)
 sets the current predicate.
void setTerm (const char *fName1, ComparisionOp op, const char *fName2)
 sets the predicate term of form f1 = f2.
void setTerm (const char *fName1, ComparisionOp op, void *opnd)
 sets the predicate term of form f1 = 10
void setTerm (const char *fName1, ComparisionOp op, void **opnd)
 sets the predicate term of form f1 =10, using pointer semantics
void setTerm (Predicate *p1, LogicalOp op, Predicate *p2=NULL)
 sets the predicate term of form f1 = f2 && f1 = 100.

Detailed Description

Represents the condition part of SQL Query.

Used in SELECT, UPDATE and DELETE statement to retrieve only tuples which satisfy
the condition. This represents the root of the logical expression. This logical
expression may contain multiple terms(predicates).
For example to set this condition f1 == f2 && f1 == 100.
Condition c1;
int val1 = 100;
c1.setTerm("f1", OpEquals, &val1);
Predicate *p1 = c1.getPredicate();
Condition c2;
c2.setTerm("f1", opEquals, "f2");
Predicate *p2 = c2.getPredicate();
Condtion rootCondition;
rootCondition.setTerm(p1, OpAnd, p2);
table->setCondition(rootCondition);

Author:
Prabakaran Thirumalai

Definition at line 42 of file Predicate.h.


Constructor & Destructor Documentation

Condition::Condition (  ) 

Definition at line 19 of file Condition.cxx.

00020 {
00021     //pred = new PredicateImpl();
00022     pred = NULL;
00023 }

Condition::~Condition (  ) 

Definition at line 29 of file Condition.cxx.

00030 {
00031     if (pred) delete pred;
00032     pred = NULL;
00033 }


Member Function Documentation

Predicate* Condition::getPredicate (  )  [inline]

gets the current predicate.

This is used to create logical expressions with terms or predicates.

Returns:
Predicate* predicate

Definition at line 53 of file Predicate.h.

Referenced by TableImpl::setCondition().

00053 { return pred; }

Here is the caller graph for this function:

void Condition::reset (  ) 

Definition at line 24 of file Condition.cxx.

Referenced by ParsedData::reset().

00025 {
00026     if (pred) {delete pred;}
00027     pred =  NULL;
00028 }

Here is the caller graph for this function:

void Condition::setPredicate ( Predicate predicate  )  [inline]

sets the current predicate.

This is set after creating the logical expression and used in the table interface for setting the condition.

Parameters:
Predicate* predicate

Definition at line 58 of file Predicate.h.

Referenced by ParsedData::setCondition().

00058 {  pred = predicate; }

Here is the caller graph for this function:

void Condition::setTerm ( Predicate p1,
LogicalOp  op,
Predicate p2 = NULL 
)

sets the predicate term of form f1 = f2 && f1 = 100.

Parameters:
p1* predicate
op logical operator (&&, ||, !)
p2* predicate

Definition at line 57 of file Condition.cxx.

References Predicate::setTerm().

00058 {
00059     if (pred) delete pred;
00060     pred = new PredicateImpl();
00061     pred->setTerm(p1, op, p2);
00062 }

Here is the call graph for this function:

void Condition::setTerm ( const char *  fName1,
ComparisionOp  op,
void **  opnd 
)

sets the predicate term of form f1 =10, using pointer semantics

Parameters:
fName1* field name
op comparision operator(=,!=, >,<,>=,<=)
opnd** pointer to pointer to the value

Definition at line 50 of file Condition.cxx.

References Predicate::setTerm().

00051 {
00052     if (pred) delete pred;
00053     pred = new PredicateImpl();
00054     pred->setTerm(fName1, op, opnd);
00055 }

Here is the call graph for this function:

void Condition::setTerm ( const char *  fName1,
ComparisionOp  op,
void *  opnd 
)

sets the predicate term of form f1 = 10

Parameters:
fName1* field name
op comparision operator(=,!=, >,<,>=,<=)
opnd* pointer to the value

Definition at line 43 of file Condition.cxx.

References Predicate::setTerm().

00044 {
00045     if (pred) delete pred;
00046     pred = new PredicateImpl();
00047     pred->setTerm(fName1, op, opnd);
00048 }

Here is the call graph for this function:

void Condition::setTerm ( const char *  fName1,
ComparisionOp  op,
const char *  fName2 
)

sets the predicate term of form f1 = f2.

Parameters:
fName1* field name
op comparision operator
fName2* field name

Definition at line 34 of file Condition.cxx.

References Predicate::setTerm().

Referenced by remove().

00036 {
00037     if (pred) delete pred;
00038     pred = new PredicateImpl();
00039     pred->setTerm(fName1, op, fName2);
00040 }

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 22:44:33 2008 for csql by  doxygen 1.4.7