BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
rdbModel::Connection Class Referenceabstract

#include <Connection.h>

+ Inheritance diagram for rdbModel::Connection:

Public Member Functions

 Connection ()
 
virtual ~Connection ()
 
virtual bool open (const std::string &host, const std::string &userid, const std::string &password, const std::string &dbName)=0
 
virtual bool close ()=0
 
virtual bool open (const std::string &parms)=0
 
virtual bool isConnected ()=0
 Return true iff open has been done with no matching close.
 
virtual std::ostream * getOut () const =0
 
virtual std::ostream * getErrOut () const =0
 
virtual MATCH matchSchema (Rdb *rdb, bool matchDbName=true)=0
 
virtual bool insertRow (const std::string &tableName, const StringVector &colNames, const StringVector &values, int *auto_value=0, const StringVector *nullCols=0)=0
 
virtual unsigned int update (const std::string &tableName, const StringVector &colNames, const StringVector &values, const Assertion *where=0, const StringVector *nullCols=0)=0
 
virtual ResultHandleselect (const std::string &tableName, const StringVector &getCols, const StringVector &orderCols, const Assertion *where=0, int rowLimit=0, int rowOffset=0)=0
 
virtual void disableModify (bool disable)=0
 
virtual ResultHandledbRequest (const std::string &request)=0
 
virtual bool compileAssertion (const Assertion *a, std::string &sqlString) const =0
 
 Connection ()
 
virtual ~Connection ()
 
virtual bool open (const std::string &host, const std::string &userid, const std::string &password, const std::string &dbName)=0
 
virtual bool close ()=0
 
virtual bool open (const std::string &parms)=0
 
virtual bool isConnected ()=0
 Return true iff open has been done with no matching close.
 
virtual std::ostream * getOut () const =0
 
virtual std::ostream * getErrOut () const =0
 
virtual MATCH matchSchema (Rdb *rdb, bool matchDbName=true)=0
 
virtual bool insertRow (const std::string &tableName, const StringVector &colNames, const StringVector &values, int *auto_value=0, const StringVector *nullCols=0)=0
 
virtual unsigned int update (const std::string &tableName, const StringVector &colNames, const StringVector &values, const Assertion *where=0, const StringVector *nullCols=0)=0
 
virtual ResultHandleselect (const std::string &tableName, const StringVector &getCols, const StringVector &orderCols, const Assertion *where=0, int rowLimit=0, int rowOffset=0)=0
 
virtual void disableModify (bool disable)=0
 
virtual ResultHandledbRequest (const std::string &request)=0
 
virtual bool compileAssertion (const Assertion *a, std::string &sqlString) const =0
 

Detailed Description

Constructor & Destructor Documentation

◆ Connection() [1/2]

rdbModel::Connection::Connection ( )
inline

Open a connection Allowed operations will depend on userid, etc., specified return true if successful

Definition at line 60 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Db/Connection.h.

60{};

◆ ~Connection() [1/2]

virtual rdbModel::Connection::~Connection ( )
inlinevirtual

◆ Connection() [2/2]

rdbModel::Connection::Connection ( )
inline

Open a connection Allowed operations will depend on userid, etc., specified return true if successful

Definition at line 60 of file InstallArea/include/rdbModel/rdbModel/Db/Connection.h.

60{};

◆ ~Connection() [2/2]

virtual rdbModel::Connection::~Connection ( )
inlinevirtual

Definition at line 61 of file InstallArea/include/rdbModel/rdbModel/Db/Connection.h.

61{};

Member Function Documentation

◆ close() [1/2]

virtual bool rdbModel::Connection::close ( )
pure virtual

Close the current open connection , if any. Return true if there was a connection to close and it was closed successfully

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

Referenced by calibUtil::Metadata::disconnectRead(), ConnectionDBBase::disconnectRead(), calibUtil::Metadata::disconnectWrite(), and ConnectionDBBase::disconnectWrite().

◆ close() [2/2]

virtual bool rdbModel::Connection::close ( )
pure virtual

Close the current open connection , if any. Return true if there was a connection to close and it was closed successfully

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ compileAssertion() [1/2]

virtual bool rdbModel::Connection::compileAssertion ( const Assertion a,
std::string &  sqlString 
) const
pure virtual

compile method for assertions. Use it internally, but also make it publicly available so assertions belonging to a table can save the compiled version.

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ compileAssertion() [2/2]

virtual bool rdbModel::Connection::compileAssertion ( const Assertion a,
std::string &  sqlString 
) const
pure virtual

compile method for assertions. Use it internally, but also make it publicly available so assertions belonging to a table can save the compiled version.

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ dbRequest() [1/2]

virtual ResultHandle * rdbModel::Connection::dbRequest ( const std::string &  request)
pure virtual

Transmit raw request of any form to database. If it is a request that returns results, those results will be stored in a newly- allocated ResultHandle and dbRequest will return a pointer to it. Otherwise dbRequest will return a null pointer. Throw an exception if request fails for any reason.

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ dbRequest() [2/2]

virtual ResultHandle * rdbModel::Connection::dbRequest ( const std::string &  request)
pure virtual

Transmit raw request of any form to database. If it is a request that returns results, those results will be stored in a newly- allocated ResultHandle and dbRequest will return a pointer to it. Otherwise dbRequest will return a null pointer. Throw an exception if request fails for any reason.

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ disableModify() [1/2]

virtual void rdbModel::Connection::disableModify ( bool  disable)
pure virtual

Turn select and update into no-ops: output SQL string for debugging but don't change db

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ disableModify() [2/2]

virtual void rdbModel::Connection::disableModify ( bool  disable)
pure virtual

Turn select and update into no-ops: output SQL string for debugging but don't change db

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ getErrOut() [1/2]

virtual std::ostream * rdbModel::Connection::getErrOut ( ) const
pure virtual

◆ getErrOut() [2/2]

virtual std::ostream * rdbModel::Connection::getErrOut ( ) const
pure virtual

◆ getOut() [1/2]

virtual std::ostream * rdbModel::Connection::getOut ( ) const
pure virtual

◆ getOut() [2/2]

virtual std::ostream * rdbModel::Connection::getOut ( ) const
pure virtual

◆ insertRow() [1/2]

virtual bool rdbModel::Connection::insertRow ( const std::string &  tableName,
const StringVector colNames,
const StringVector values,
int *  auto_value = 0,
const StringVector nullCols = 0 
)
pure virtual

Typical derived class will form a syntactically correct INSERT statement from the input arguments and issue it to the dbms. Return true if row was inserted successfully

Might also want to add a routine for INSERT ... SELECT

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

Referenced by rdbModel::Table::insertLatest(), rdbModel::Table::insertRow(), and calibUtil::Metadata::registerCalib().

◆ insertRow() [2/2]

virtual bool rdbModel::Connection::insertRow ( const std::string &  tableName,
const StringVector colNames,
const StringVector values,
int *  auto_value = 0,
const StringVector nullCols = 0 
)
pure virtual

Typical derived class will form a syntactically correct INSERT statement from the input arguments and issue it to the dbms. Return true if row was inserted successfully

Might also want to add a routine for INSERT ... SELECT

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ isConnected() [1/2]

virtual bool rdbModel::Connection::isConnected ( )
pure virtual

Return true iff open has been done with no matching close.

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ isConnected() [2/2]

virtual bool rdbModel::Connection::isConnected ( )
pure virtual

Return true iff open has been done with no matching close.

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ matchSchema() [1/2]

virtual MATCH rdbModel::Connection::matchSchema ( Rdb rdb,
bool  matchDbName = true 
)
pure virtual

Check to what degree local schema definition is compatible with remote db accessed via this connection. By default check db names match, but this may be disabled.

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ matchSchema() [2/2]

virtual MATCH rdbModel::Connection::matchSchema ( Rdb rdb,
bool  matchDbName = true 
)
pure virtual

Check to what degree local schema definition is compatible with remote db accessed via this connection. By default check db names match, but this may be disabled.

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ open() [1/4]

virtual bool rdbModel::Connection::open ( const std::string &  host,
const std::string &  userid,
const std::string &  password,
const std::string &  dbName 
)
pure virtual

◆ open() [2/4]

virtual bool rdbModel::Connection::open ( const std::string &  host,
const std::string &  userid,
const std::string &  password,
const std::string &  dbName 
)
pure virtual

◆ open() [3/4]

virtual bool rdbModel::Connection::open ( const std::string &  parms)
pure virtual

Parameter is normally path for an xml file descrbing the connection parameters

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ open() [4/4]

virtual bool rdbModel::Connection::open ( const std::string &  parms)
pure virtual

Parameter is normally path for an xml file descrbing the connection parameters

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ select() [1/2]

virtual ResultHandle * rdbModel::Connection::select ( const std::string &  tableName,
const StringVector getCols,
const StringVector orderCols,
const Assertion where = 0,
int  rowLimit = 0,
int  rowOffset = 0 
)
pure virtual

Support only for relatively simple SELECT, involving just one table.

Parameters
tableName
getColsvector of columns to be retrieved
whereptr to an Assertion object
rowLimitmax number of rows to return
rowOffsetoffset for first row returned among those satisfying conditions; ignored if 0.
Returns
If the SELECT succeeds, a pointer to an object which manages the returned data; else 0. Caller is responsible for deleting the ResultHandle object.

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

Referenced by Coverage::checkType(), calibUtil::Metadata::getReadInfo(), rdbModel::Table::insertLatest(), and rdbModel::Table::supersedeRow().

◆ select() [2/2]

virtual ResultHandle * rdbModel::Connection::select ( const std::string &  tableName,
const StringVector getCols,
const StringVector orderCols,
const Assertion where = 0,
int  rowLimit = 0,
int  rowOffset = 0 
)
pure virtual

Support only for relatively simple SELECT, involving just one table.

Parameters
tableName
getColsvector of columns to be retrieved
whereptr to an Assertion object
rowLimitmax number of rows to return
rowOffsetoffset for first row returned among those satisfying conditions; ignored if 0.
Returns
If the SELECT succeeds, a pointer to an object which manages the returned data; else 0. Caller is responsible for deleting the ResultHandle object.

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

◆ update() [1/2]

virtual unsigned int rdbModel::Connection::update ( const std::string &  tableName,
const StringVector colNames,
const StringVector values,
const Assertion where = 0,
const StringVector nullCols = 0 
)
pure virtual

Generic UPDATE. Return value is number of rows changed.

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.

Referenced by rdbModel::Table::updateRows().

◆ update() [2/2]

virtual unsigned int rdbModel::Connection::update ( const std::string &  tableName,
const StringVector colNames,
const StringVector values,
const Assertion where = 0,
const StringVector nullCols = 0 
)
pure virtual

Generic UPDATE. Return value is number of rows changed.

Implemented in rdbModel::MysqlConnection, and rdbModel::MysqlConnection.


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