Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

rdbModel::Assertion Class Reference

#include <Assertion.h>

List of all members.

Public Member Functions

Visitor::VisitorState accept (Visitor *v)
Visitor::VisitorState accept (Visitor *v)
 Assertion (const Assertion *orig, Row *toBe)
 Assertion (Operator *op=0, Table *myTable=0, bool keepOp=false)
 Assertion (const Assertion *orig, Row *toBe)
 Assertion (Operator *op=0, Table *myTable=0, bool keepOp=false)
const std::string & getName () const
const std::string & getName () const
bool getOld () const
bool getOld () const
OperatorgetOperator () const
OperatorgetOperator () const
const std::string & getPrecompiled () const
const std::string & getPrecompiled () const
bool getToBe () const
bool getToBe () const
void setName (const std::string &name)
void setName (const std::string &name)
bool verify (Row &old, Row &toBe) const
bool verify (Row &old, Row &toBe) const
 ~Assertion ()
 ~Assertion ()

Private Attributes

std::string m_compiled
bool m_keepOp
Tablem_myTable
Tablem_myTable
std::string m_name
 Assertions have names so that they can be referenced elsewhere.
Operatorm_op
 The heart of an Assertion is an Operator.
Operatorm_op
 The heart of an Assertion is an Operator.


Detailed Description

Assertions are used in at least two ways: 1. As part of a table description. The assertion describes a condition which should be evaluated upon a particular event, such as when a new element is to be inserted. Such assertions stick around for the life of the application instance. If the assertion is checked often, a pre-compiled version (dependent on the type of connection) can save some time. 2. As a WHERE clause in a client-institued UPDATE or SELECT. These are only around long enough to do the UPDATE or SELECT.

The bulk of the information comprising an assertion is kept in a tree whose nodes are "operations". An operation may be either a comparison ( =, <=, etc. and also "is null") or an operation which has child operations: OR, AND, NOT, for all, there exists, hence a node is a leaf node iff it's a comparison.

Once an operation has been incorporated into an Assertion or into another operation, it is 'owned' by this parent. Deleting the parent will cause its children to be deleted. Hence applications building assertions out of operators should never delete those operators.


Constructor & Destructor Documentation

rdbModel::Assertion::Assertion Operator op = 0,
Table myTable = 0,
bool  keepOp = false
[inline]
 

Normally, operator associated with the assertion will be deleted when the assertion itself is deleted, but this won't happen if keepOp is set to true.

00180                                                                      : 
00181       m_op(op), m_myTable(myTable), m_keepOp(keepOp)
00182     { m_compiled.clear(); m_name.clear();};

rdbModel::Assertion::Assertion const Assertion orig,
Row toBe
 

Copy original assertion, but, wherever a colRef is a "toBe", substitute with value from toBe row. toBe is not const because we may need to sort it.

00024     : m_op(0), m_myTable(orig->m_myTable), m_keepOp(false), m_name(""),
00025       m_compiled("") {
00026     toBe->rowSort();
00027     m_op = new Assertion::Operator(orig->m_op, toBe);
00028 
00029   }

rdbModel::Assertion::~Assertion  ) 
 

00031                         {
00032     if (!m_keepOp) delete m_op;
00033   }

rdbModel::Assertion::Assertion Operator op = 0,
Table myTable = 0,
bool  keepOp = false
[inline]
 

Normally, operator associated with the assertion will be deleted when the assertion itself is deleted, but this won't happen if keepOp is set to true.

00180                                                                      : 
00181       m_op(op), m_myTable(myTable), m_keepOp(keepOp)
00182     { m_compiled.clear(); m_name.clear();};

rdbModel::Assertion::Assertion const Assertion orig,
Row toBe
 

Copy original assertion, but, wherever a colRef is a "toBe", substitute with value from toBe row. toBe is not const because we may need to sort it.

rdbModel::Assertion::~Assertion  ) 
 


Member Function Documentation

Visitor::VisitorState rdbModel::Assertion::accept Visitor v  ) 
 

Visitor::VisitorState rdbModel::Assertion::accept Visitor v  ) 
 

00344                                                    {
00345     Visitor::VisitorState state = v->visitAssertion(this);
00346     if (state == Visitor::VBRANCHDONE) return Visitor::VCONTINUE;
00347     return state;
00348   }

const std::string& rdbModel::Assertion::getName  )  const [inline]
 

00207 {return m_name;}

const std::string& rdbModel::Assertion::getName  )  const [inline]
 

00207 {return m_name;}

bool rdbModel::Assertion::getOld  )  const [inline]
 

Returns true if associated operator or descendant refers to existing row

00205 {return m_op->getOld();}

bool rdbModel::Assertion::getOld  )  const [inline]
 

Returns true if associated operator or descendant refers to existing row

00205 {return m_op->getOld();}

Operator* rdbModel::Assertion::getOperator  )  const [inline]
 

00195 {return m_op;}

Operator* rdbModel::Assertion::getOperator  )  const [inline]
 

00195 {return m_op;}

const std::string& rdbModel::Assertion::getPrecompiled  )  const [inline]
 

00197 {return m_compiled;}

const std::string& rdbModel::Assertion::getPrecompiled  )  const [inline]
 

00197 {return m_compiled;}

bool rdbModel::Assertion::getToBe  )  const [inline]
 

True if associated operator or descendant refers to future row (in which case can't call MySql::compileAssertion)

00201 {return m_op->getToBe();}

bool rdbModel::Assertion::getToBe  )  const [inline]
 

True if associated operator or descendant refers to future row (in which case can't call MySql::compileAssertion)

00201 {return m_op->getToBe();}

void rdbModel::Assertion::setName const std::string &  name  )  [inline]
 

00208 {m_name = name;}

void rdbModel::Assertion::setName const std::string &  name  )  [inline]
 

00208 {m_name = name;}

bool rdbModel::Assertion::verify Row old,
Row toBe
const
 

verify checks if assertion (which may refer to one or both of an old row and a proposed row) holds for these arguments. Caller is responsible for fetching old row fields out of dbs if necessary May throw RdbException

bool rdbModel::Assertion::verify Row old,
Row toBe
const
 

verify checks if assertion (which may refer to one or both of an old row and a proposed row) holds for these arguments. Caller is responsible for fetching old row fields out of dbs if necessary May throw RdbException

00350                                                    {
00351 
00352     if (getOld() ) { // will actually use old vector, so sort
00353       old.rowSort();
00354     }
00355     if (getToBe() ) { // will actually use toBe vector, so sort
00356       toBe.rowSort();
00357     }
00358     return m_op->verify(old, toBe, m_myTable);
00359   }


Member Data Documentation

std::string rdbModel::Assertion::m_compiled [private]
 

Let's hope that, independent of connection type, std::string is a reasonable choice for "compiled" form of the assertion

bool rdbModel::Assertion::m_keepOp [private]
 

m_keepOp indicates whether or not we're responsible for cleaning up resources

Table* rdbModel::Assertion::m_myTable [private]
 

Table* rdbModel::Assertion::m_myTable [private]
 

std::string rdbModel::Assertion::m_name [private]
 

Assertions have names so that they can be referenced elsewhere.

Operator* rdbModel::Assertion::m_op [private]
 

The heart of an Assertion is an Operator.

Operator* rdbModel::Assertion::m_op [private]
 

The heart of an Assertion is an Operator.


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 19:21:52 2011 for BOSS6.5.5 by  doxygen 1.3.9.1