BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
rdbModel::Assertion Class Reference

#include <Assertion.h>

Classes

class  Operator
 

Public Member Functions

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

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.

Definition at line 56 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Assertion.h.

Constructor & Destructor Documentation

◆ Assertion() [1/2]

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.

Definition at line 180 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Assertion.h.

180 :
181 m_op(op), m_myTable(myTable), m_keepOp(keepOp)
182 { m_compiled.clear(); m_name.clear();};

◆ Assertion() [2/2]

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.

Definition at line 23 of file Calibration/rdbModel/rdbModel-00-01-01/src/Tables/Assertion.cxx.

24 : m_op(0), m_myTable(orig->m_myTable), m_keepOp(false), m_name(""),
25 m_compiled("") {
26 toBe->rowSort();
27 m_op = new Assertion::Operator(orig->m_op, toBe);
28
29 }

◆ ~Assertion()

rdbModel::Assertion::~Assertion ( )

Definition at line 31 of file Calibration/rdbModel/rdbModel-00-01-01/src/Tables/Assertion.cxx.

31 {
32 if (!m_keepOp) delete m_op;
33 }

Member Function Documentation

◆ accept()

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

Definition at line 344 of file Calibration/rdbModel/rdbModel-00-01-01/src/Tables/Assertion.cxx.

344 {
345 Visitor::VisitorState state = v->visitAssertion(this);
346 if (state == Visitor::VBRANCHDONE) return Visitor::VCONTINUE;
347 return state;
348 }
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition KarLud.h:35

◆ getName()

const std::string & rdbModel::Assertion::getName ( ) const
inline

◆ getOld()

bool rdbModel::Assertion::getOld ( ) const
inline

Returns true if associated operator or descendant refers to existing row

Definition at line 205 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Assertion.h.

205{return m_op->getOld();}
bool getOld() const
True if operator or sub-operator refers to existing row.

Referenced by verify().

◆ getOperator()

Operator * rdbModel::Assertion::getOperator ( ) const
inline

◆ getPrecompiled()

const std::string & rdbModel::Assertion::getPrecompiled ( ) const
inline

Definition at line 197 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Assertion.h.

197{return m_compiled;}

◆ 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)

Definition at line 201 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Assertion.h.

201{return m_op->getToBe();}
bool getToBe() const
True if operator or sub-operator refers to future row.

Referenced by verify().

◆ setName()

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

Definition at line 208 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Assertion.h.

208{m_name = name;}

◆ verify()

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

Definition at line 350 of file Calibration/rdbModel/rdbModel-00-01-01/src/Tables/Assertion.cxx.

350 {
351
352 if (getOld() ) { // will actually use old vector, so sort
353 old.rowSort();
354 }
355 if (getToBe() ) { // will actually use toBe vector, so sort
356 toBe.rowSort();
357 }
358 return m_op->verify(old, toBe, m_myTable);
359 }
bool verify(Row &old, Row &toBe, Table *t) const
Evaluate operator on argument Rows.

Referenced by rdbModel::Table::insertLatest(), rdbModel::Table::insertRow(), main(), and rdbModel::Assertion::Operator::verify().


The documentation for this class was generated from the following files: