UNIVERS
15.3
UNIVERS base processing software API
|
#include <qsql_impl.hpp>
Classes | |
struct | TableLockDescr |
Public Types | |
enum | TableLockType { TLT_READ = 0, TLT_WRITE } |
typedef std::vector < TableLockDescr > | TLDVec |
Public Member Functions | |
QSqlImpl () | |
QSqlImpl (const ContextQSql &dbc) | |
virtual | ~QSqlImpl () |
const ContextQSql & | getDbContext () const |
QSqlDatabase & | getDb () |
bool | supportTransactionsFlag () const |
ErrCode | dbConnect () const |
QMutex & | getDefaultMutex () const |
Protected Member Functions | |
ErrCode | db_init (const hds::db::ContextQSql &context) |
ErrCode | db_close (const hds::db::ContextQSql &context) |
ErrCode | db_lock_tables (const TLDVec &tld_vec) |
ErrCode | db_release_tables_locks () |
ErrCode | db_get_lock (const std::string &lock_name, const size_t timeout=3) const |
ErrCode | db_release_lock (const std::string &lock_name) const |
ErrCode | db_set_item_value (const std::string &table_name, const std::string &field_name, const std::string &key_name, const DbIndex &key_id, const std::string &value) |
ErrCode | db_get_item_value (const std::string &table_name, const std::string &field_name, const std::string &key_name, const DbIndex &key_id, std::string &value) const |
time_t | db_table_creation_time (const std::string &table_name, ErrCode *prc=NULL) const |
time_t | db_table_modification_time (const std::string &table_name, ErrCode *prc=NULL) const |
quint64 | db_table_size (const std::string &table_name, ErrCode *prc=NULL) const |
size_t | db_table_rows_num (const std::string &table_name, ErrCode *prc=NULL) const |
ErrCode | db_transaction_begin () const |
ErrCode | db_transaction_commit () |
ErrCode | db_transaction_rollback () |
QString | get_db_name_hash (const hds::db::ContextQSql &context) const |
Protected Attributes | |
QSqlDatabase | m_db |
ContextQSql | m_dbc |
bool | m_is_transaction_started |
Implementation of common methods using Qt SQL features.
typedef std::vector<TableLockDescr> hds::db::QSqlImpl::TLDVec |
Vector of table locks descriptions.
hds::db::QSqlImpl::QSqlImpl | ( | ) |
Default constructor.
hds::db::QSqlImpl::QSqlImpl | ( | const ContextQSql & | dbc | ) |
Constructor with database context provided.
|
virtual |
Destructor.
|
protected |
Close database session associated with provided context.
Return EC_NO_ERROR if all ok.
|
protected |
Get value of the row item with provided key id for table with provided name.
Return EC_NO_ERROR if all ok.
|
protected |
Tries to make database lock (mutex) with provided name and waiting timeout.
lock_name | Name of the lock. |
timeout | Lock try waiting timeout (s). |
|
protected |
Initialize database session associated with provided context.
Return EC_NO_ERROR if all ok.
Try to lock tables provided with table locks descriptions.
|
protected |
Releases database lock (mutex) with provided name.
lock_name | Name of the lock. |
|
protected |
Unlock all tables in the session.
|
protected |
Set value of the row item with provided key id for table with provided name.
Return EC_NO_ERROR if all ok.
|
protected |
Get table creation time.
table_name | Name of the table. |
prc | Resulted error code, EC_NO_ERROR if all ok. |
|
protected |
Get table creation time.
table_name | Name of the table. |
prc | Resulted error code, EC_NO_ERROR if all ok. |
|
protected |
Get number of rows of table with provided name.
table_name | Name of the table. |
prc | Resulted error code, EC_NO_ERROR if all ok. |
|
protected |
Get size of table with provided name.
table_name | Name of the table. |
prc | Resulted error code, EC_NO_ERROR if all ok. |
|
protected |
Start transaction.
Do nothing if transaction not supported, this case not a error. Do nothing if transaction is started, this case not a error.
|
protected |
Commit transaction.
Do nothing if transaction not supported, this case not a error. Do nothing if transaction not started, this case not a error.
|
protected |
Rollback transaction.
Do nothing if transaction not supported, this case not a error. Do nothing if transaction not started, this case not a error.
ErrCode hds::db::QSqlImpl::dbConnect | ( | ) | const |
Connect to db with provided context. Do nothing if already connected.
Return EC_NO_ERROR if all ok.
|
protected |
Get database name hash for provided database context.
|
inline |
Access to database.
|
inline |
Access to current database condext.
QMutex& hds::db::QSqlImpl::getDefaultMutex | ( | ) | const |
Access to default mutex object.
bool hds::db::QSqlImpl::supportTransactionsFlag | ( | ) | const |
Returrn true or false if database provides or not provides transactions.
|
mutableprotected |
< SQL database connector. Data base context.
|
protected |
Is transaction started flag.