MT Showcase SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Showcase::DatabaseManager Class Reference

This class provides a thin wrapper around database connections using QSqlDatabase. More...

#include <DatabaseManager.hpp>

Static Public Member Functions

static QSqlDatabase connection (const QString &baseConnectionName)
 Get a thread-specific database connection. More...
 
static bool supportsProtocol (const QString &protocol)
 Check if the given database protocol is supported. More...
 

Detailed Description

This class provides a thin wrapper around database connections using QSqlDatabase.

QSqlDatabase objects are created based on a common base connection name. A unique suffix is added to each connection name based on the calling thread. All connection instances with the same base name and calling thread are shared. The returned QSqlDatabase objects must not be passed between threads. This class also assumes that no function calls to QSqlDatabase that are not thread-safe are performed elsewhere.

Member Function Documentation

QSqlDatabase Showcase::DatabaseManager::connection ( const QString &  baseConnectionName)
static

Get a thread-specific database connection.

This function will return a database connection specific to the calling thread. The returned connection must not be used from different threads. This function is thread-safe.

Parameters
baseConnectionNamename for the database connection
Returns
database connection
bool Showcase::DatabaseManager::supportsProtocol ( const QString &  protocol)
static

Check if the given database protocol is supported.

Parameters
protocolprotocol to check
Returns
true if the protocol is supported; otherwise false