|
JAPAn
Just Another Parity Analyzer
|
A database interface class. More...
#include <QwDatabase.h>
Collaboration diagram for QwDatabase:Public Member Functions | |
| template<typename Statement, typename Lambda> | |
| void | QuerySelectForEachResult (const Statement &statement, Lambda &&lambda) |
| template<typename QueryResult, typename Lambda> | |
| void | ForEachResult (QueryResult &result, Lambda &&lambda) const |
| template<typename Statement> | |
| size_t | QuerySelectCountResults (const Statement &statement) |
| template<typename QueryResult> | |
| size_t | CountResults (QueryResult &result) const |
| template<typename Statement, typename Lambda> | |
| bool | QuerySelectForFirstResult (const Statement &statement, Lambda &&lambda) |
| template<typename QueryResult, typename Lambda> | |
| bool | ForFirstResult (QueryResult &result, Lambda &&lambda) const |
| template<typename Statement, typename Lambda> | |
| auto | VisitConnectionForSelect (Lambda &&lambda) -> QuerySelectReturnType< Statement > |
| QwDatabase (const string &major="00", const string &minor="00", const string &point="0000") | |
| Simple constructor. | |
| QwDatabase (QwOptions &options, const string &major="00", const string &minor="00", const string &point="0000") | |
| Constructor with QwOptions object. | |
| virtual | ~QwDatabase () |
| Destructor. | |
| void | SetAccessLevel (string accesslevel) |
| Sets the access level flag based on string labels: "off", "ro", "rw". | |
| Bool_t | AllowsReadAccess () |
| Bool_t | AllowsWriteAccess () |
| Bool_t | Connect () |
| Open a connection to the database using the predefined parameters. | |
| void | Disconnect () |
| Bool_t | Connected () |
| Get a scoped connection that automatically disconnects when destroyed. | |
| QwScopedConnection | GetScopedConnection () |
| const string | GetServerVersion () |
| void | ProcessOptions (QwOptions &options) |
| Processes the options contained in the QwOptions object. | |
| void | ProcessOptions (const EQwDBType &dbtype, const TString &dbname, const TString &username, const TString &passwd, const TString &dbhost="localhost", const Int_t dbport=0, const TString &accesslevel="ro") |
| Processes database options. | |
| template<typename Statement> | |
| size_t | QueryCount (const Statement &statement) |
| template<typename Statement> | |
| bool | QueryExists (const Statement &statement) |
| template<typename Statement> | |
| auto | QuerySelect (const Statement &statement) |
| template<typename Statement> | |
| void | QueryExecute (const Statement &statement) |
| template<typename InsertStatement> | |
| uint64_t | QueryInsertAndGetId (const InsertStatement &statement) |
| const string | GetVersion () |
| const string | GetVersionMajor () |
| Return a full version string for the DB schema. | |
| const string | GetVersionMinor () |
| const string | GetVersionPoint () |
| const string | GetValidVersion () |
| void | PrintServerInfo () |
Static Public Member Functions | |
| static void | DefineOptions (QwOptions &options) |
| Defines available class options for QwOptions. | |
Protected Attributes | |
| Bool_t | fDBInsertMissingKeys |
| True if missing keys should be inserted into the database automatically. | |
Private Types | |
| enum | EQwDBType { kQwDatabaseNone } |
| enum class | EConnectionCheck : bool { kUnchecked = false , kChecked = true } |
| enum | EQwDBAccessLevel { kQwDatabaseOff , kQwDatabaseReadOnly , kQwDatabaseReadWrite } |
| using | DatabaseConnection |
| template<typename Statement> | |
| using | QuerySelectReturnType |
Private Member Functions | |
| template<EConnectionCheck CheckConnection = EConnectionCheck::kChecked, typename Lambda> | |
| auto | VisitConnection (Lambda &&lambda) |
| Bool_t | ValidateConnection () |
| Checks that given connection parameters result in a valid connection. | |
| bool | StoreDBVersion () |
| Retrieve database schema version information from database. | |
| QwDatabase (const QwDatabase &rhs) | |
| Copy Constructor (not implemented) | |
| QwDatabase & | operator= (const QwDatabase &rhs) |
| Assignment operator (not implemented) | |
Private Attributes | |
| EQwDBType | fDBType = kQwDatabaseNone |
| Type of database backend to use. | |
| DatabaseConnection | fDBConnection |
| EQwDBAccessLevel | fAccessLevel |
| Access level of the database instance. | |
| string | fDatabase |
| Name of database to connect to. | |
| string | fDBServer |
| Name of server carrying DB to connect to. | |
| string | fDBUsername |
| Name of account to connect to DB server with. | |
| string | fDBPassword |
| DB account password. | |
| UInt_t | fDBPortNumber |
| Port number to connect to on server (mysql default port is 3306) | |
| Bool_t | fValidConnection |
| True if a valid connection was established using defined connection information. | |
| Bool_t | fDBDebug |
| True if database debug information should be printed to stdout. | |
| string | fVersionMajor |
| Major version number of current DB schema. | |
| string | fVersionMinor |
| Minor version number of current DB schema. | |
| string | fVersionPoint |
| Point version number of current DB schema. | |
| const string | kValidVersionMajor |
| const string | kValidVersionMinor |
| const string | kValidVersionPoint |
A database interface class.
This class provides the connection to the Qweak database to other objects in the Qweak analyzer. A static global object gQwDatabase is used to provide these services.
Definition at line 121 of file QwDatabase.h.
|
private |
Definition at line 148 of file QwDatabase.h.
|
private |
Definition at line 163 of file QwDatabase.h.
|
strongprivate |
| Enumerator | |
|---|---|
| kUnchecked | |
| kChecked | |
Definition at line 180 of file QwDatabase.h.
|
private |
| Enumerator | |
|---|---|
| kQwDatabaseOff | |
| kQwDatabaseReadOnly | |
| kQwDatabaseReadWrite | |
Definition at line 419 of file QwDatabase.h.
|
private |
| Enumerator | |
|---|---|
| kQwDatabaseNone | |
Definition at line 123 of file QwDatabase.h.
| QwDatabase::QwDatabase | ( | const string & | major = "00", |
| const string & | minor = "00", | ||
| const string & | point = "0000" ) |
Simple constructor.
The simple constructor initializes member fields. This class is not used to establish the database connection.
Definition at line 78 of file QwDatabase.cc.
References QwLog::endl(), fAccessLevel, fDatabase, fDBPassword, fDBPortNumber, fDBServer, fDBUsername, fValidConnection, fVersionMajor, fVersionMinor, fVersionPoint, kQwDatabaseOff, kValidVersionMajor, kValidVersionMinor, kValidVersionPoint, and QwDebug.
Referenced by operator=(), and QwDatabase().
Here is the call graph for this function:
Here is the caller graph for this function:| QwDatabase::QwDatabase | ( | QwOptions & | options, |
| const string & | major = "00", | ||
| const string & | minor = "00", | ||
| const string & | point = "0000" ) |
Constructor with QwOptions object.
The constructor initializes member fields using the values in the QwOptions object.
| options | The QwOptions object. |
| major | Major version number |
| minor | Minor version number |
| point | Point revision number |
Definition at line 100 of file QwDatabase.cc.
References QwLog::endl(), fAccessLevel, fDatabase, fDBPassword, fDBPortNumber, fDBServer, fDBUsername, fValidConnection, fVersionMajor, fVersionMinor, fVersionPoint, kQwDatabaseOff, kValidVersionMajor, kValidVersionMinor, kValidVersionPoint, ProcessOptions(), and QwDebug.
Here is the call graph for this function:
|
virtual |
Destructor.
The destructor says "Good-bye World!"
Definition at line 119 of file QwDatabase.cc.
References Connected(), Disconnect(), QwLog::endl(), and QwDebug.
Here is the call graph for this function:
|
private |
Copy Constructor (not implemented)
References QwDatabase().
Here is the call graph for this function:
|
inline |
Definition at line 309 of file QwDatabase.h.
References fAccessLevel, kQwDatabaseReadOnly, and kQwDatabaseReadWrite.
|
inline |
| bool QwDatabase::Connect | ( | ) |
Open a connection to the database using the predefined parameters.
This function is used to initiate a database connection.
Definition at line 303 of file QwDatabase.cc.
References Connected(), QwLog::endl(), fAccessLevel, fDatabase, fDBConnection, fDBDebug, fDBPassword, fDBPortNumber, fDBServer, fDBType, fDBUsername, fValidConnection, kQwDatabaseOff, QwDebug, QwError, QwMessage, and ValidateConnection().
Here is the call graph for this function:
|
inline |
Get a scoped connection that automatically disconnects when destroyed.
Definition at line 323 of file QwDatabase.h.
References VisitConnection().
Referenced by Connect(), and ~QwDatabase().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 248 of file QwDatabase.h.
References ForEachResult().
Here is the call graph for this function:
|
static |
Defines available class options for QwOptions.
Defines configuration options for QwDatabase class using QwOptions functionality.
Should apparently by called by QwOptions::DefineOptions() in QwParityOptions.h
Definition at line 409 of file QwDatabase.cc.
References QwOptions::AddOptions().
Referenced by QwOptions::DefineOptions().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 313 of file QwDatabase.h.
References VisitConnection().
Referenced by StoreDBVersion(), ValidateConnection(), and ~QwDatabase().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 223 of file QwDatabase.h.
Referenced by CountResults(), ForFirstResult(), and QuerySelectForEachResult().
Here is the caller graph for this function:
|
inline |
Definition at line 272 of file QwDatabase.h.
References ForEachResult().
Referenced by StoreDBVersion().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 335 of file QwDatabase.h.
|
inline |
Definition at line 338 of file QwDatabase.h.
Referenced by PrintServerInfo().
Here is the caller graph for this function:| const string QwDatabase::GetValidVersion | ( | ) |
Definition at line 558 of file QwDatabase.cc.
References kValidVersionMajor, kValidVersionMinor, and kValidVersionPoint.
Referenced by ValidateConnection().
Here is the caller graph for this function:| const string QwDatabase::GetVersion | ( | ) |
Definition at line 553 of file QwDatabase.cc.
References fVersionMajor, fVersionMinor, and fVersionPoint.
Referenced by ValidateConnection().
Here is the caller graph for this function:
|
inline |
Return a full version string for the DB schema.
Definition at line 411 of file QwDatabase.h.
References fVersionMajor.
|
inline |
|
inline |
|
private |
Assignment operator (not implemented)
References QwDatabase().
Here is the call graph for this function:| void QwDatabase::PrintServerInfo | ( | ) |
This function prints the server information.
Definition at line 531 of file QwDatabase.cc.
References BLUE, BOLD, fDatabase, fDBPortNumber, fDBServer, fDBUsername, fValidConnection, GetServerVersion(), NORMAL, and RED.
Here is the call graph for this function:| void QwDatabase::ProcessOptions | ( | const EQwDBType & | dbtype, |
| const TString & | dbname, | ||
| const TString & | username, | ||
| const TString & | passwd, | ||
| const TString & | dbhost = "localhost", | ||
| const Int_t | dbport = 0, | ||
| const TString & | accesslevel = "ro" ) |
Processes database options.
Definition at line 501 of file QwDatabase.cc.
References fDatabase, fDBPassword, fDBPortNumber, fDBServer, fDBType, fDBUsername, and SetAccessLevel().
Here is the call graph for this function:| void QwDatabase::ProcessOptions | ( | QwOptions & | options | ) |
Processes the options contained in the QwOptions object.
Loads the configuration options for QwDatabase class into this instance of QwDatabase from the QwOptions object.
| options | Options object |
Definition at line 443 of file QwDatabase.cc.
References QwLog::endl(), fAccessLevel, fDatabase, fDBDebug, fDBInsertMissingKeys, fDBPassword, fDBPortNumber, fDBServer, fDBType, fDBUsername, QwOptions::GetValue(), QwOptions::HasValue(), kQwDatabaseNone, kQwDatabaseOff, QwMessage, QwWarning, and SetAccessLevel().
Referenced by QwDatabase().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 348 of file QwDatabase.h.
References VisitConnection().
Referenced by QueryExists(), and StoreDBVersion().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 383 of file QwDatabase.h.
References VisitConnection().
Here is the call graph for this function:
|
inline |
Definition at line 366 of file QwDatabase.h.
References QueryCount().
Here is the call graph for this function:
|
inline |
Definition at line 393 of file QwDatabase.h.
References VisitConnection().
Here is the call graph for this function:
|
inline |
Definition at line 371 of file QwDatabase.h.
References VisitConnectionForSelect().
Referenced by QuerySelectForEachResult(), and StoreDBVersion().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 237 of file QwDatabase.h.
References QuerySelectForEachResult().
Here is the call graph for this function:
|
inline |
Definition at line 216 of file QwDatabase.h.
References ForEachResult(), and QuerySelect().
Referenced by QuerySelectCountResults(), and QuerySelectForFirstResult().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 259 of file QwDatabase.h.
References QuerySelectForEachResult().
Here is the call graph for this function:| void QwDatabase::SetAccessLevel | ( | string | accesslevel | ) |
Sets the access level flag based on string labels: "off", "ro", "rw".
Definition at line 512 of file QwDatabase.cc.
References QwLog::endl(), fAccessLevel, kQwDatabaseOff, kQwDatabaseReadOnly, kQwDatabaseReadWrite, and QwWarning.
Referenced by ProcessOptions(), and ProcessOptions().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Retrieve database schema version information from database.
Definition at line 567 of file QwDatabase.cc.
References Disconnect(), QwLog::endl(), ForFirstResult(), fVersionMajor, fVersionMinor, fVersionPoint, QueryCount(), QuerySelect(), QwDebug, and QwError.
Referenced by ValidateConnection().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Checks that given connection parameters result in a valid connection.
This function is used to load the connection information for the database. It tests the connection to make sure it is valid and causes a program exit if no valid connection can be formed.
It is called the first time Connect() is called.
Definition at line 131 of file QwDatabase.cc.
References Disconnect(), QwLog::endl(), fAccessLevel, fDatabase, fDBConnection, fDBDebug, fDBPassword, fDBPortNumber, fDBServer, fDBType, fDBUsername, fValidConnection, fVersionMajor, fVersionMinor, fVersionPoint, GetValidVersion(), GetVersion(), kQwDatabaseOff, kQwDatabaseReadWrite, kValidVersionMajor, kValidVersionMinor, kValidVersionPoint, QwDebug, QwError, QwMessage, QwWarning, and StoreDBVersion().
Referenced by Connect().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprivate |
Definition at line 187 of file QwDatabase.h.
References fDBConnection, and kChecked.
Referenced by Connected(), Disconnect(), QueryCount(), QueryExecute(), and QueryInsertAndGetId().
Here is the caller graph for this function:
|
inline |
Definition at line 285 of file QwDatabase.h.
References fDBConnection.
Referenced by QuerySelect().
Here is the caller graph for this function:
|
private |
Access level of the database instance.
Definition at line 431 of file QwDatabase.h.
Referenced by AllowsReadAccess(), AllowsWriteAccess(), Connect(), ProcessOptions(), QwDatabase(), QwDatabase(), SetAccessLevel(), and ValidateConnection().
|
private |
Name of database to connect to.
Definition at line 433 of file QwDatabase.h.
Referenced by Connect(), PrintServerInfo(), ProcessOptions(), ProcessOptions(), QwDatabase(), QwDatabase(), and ValidateConnection().
|
private |
Definition at line 176 of file QwDatabase.h.
Referenced by Connect(), ValidateConnection(), VisitConnection(), and VisitConnectionForSelect().
|
private |
True if database debug information should be printed to stdout.
Definition at line 439 of file QwDatabase.h.
Referenced by Connect(), ProcessOptions(), and ValidateConnection().
|
protected |
True if missing keys should be inserted into the database automatically.
Definition at line 449 of file QwDatabase.h.
Referenced by ProcessOptions().
|
private |
DB account password.
Definition at line 436 of file QwDatabase.h.
Referenced by Connect(), ProcessOptions(), ProcessOptions(), QwDatabase(), QwDatabase(), and ValidateConnection().
|
private |
Port number to connect to on server (mysql default port is 3306)
Definition at line 437 of file QwDatabase.h.
Referenced by Connect(), PrintServerInfo(), ProcessOptions(), ProcessOptions(), QwDatabase(), QwDatabase(), and ValidateConnection().
|
private |
Name of server carrying DB to connect to.
Definition at line 434 of file QwDatabase.h.
Referenced by Connect(), PrintServerInfo(), ProcessOptions(), ProcessOptions(), QwDatabase(), QwDatabase(), and ValidateConnection().
|
private |
Type of database backend to use.
Definition at line 134 of file QwDatabase.h.
Referenced by Connect(), ProcessOptions(), ProcessOptions(), and ValidateConnection().
|
private |
Name of account to connect to DB server with.
Definition at line 435 of file QwDatabase.h.
Referenced by Connect(), PrintServerInfo(), ProcessOptions(), ProcessOptions(), QwDatabase(), QwDatabase(), and ValidateConnection().
|
private |
True if a valid connection was established using defined connection information.
Definition at line 438 of file QwDatabase.h.
Referenced by Connect(), PrintServerInfo(), QwDatabase(), QwDatabase(), and ValidateConnection().
|
private |
Major version number of current DB schema.
Definition at line 441 of file QwDatabase.h.
Referenced by GetVersion(), GetVersionMajor(), QwDatabase(), QwDatabase(), StoreDBVersion(), and ValidateConnection().
|
private |
Minor version number of current DB schema.
Definition at line 442 of file QwDatabase.h.
Referenced by GetVersion(), GetVersionMinor(), QwDatabase(), QwDatabase(), StoreDBVersion(), and ValidateConnection().
|
private |
Point version number of current DB schema.
Definition at line 443 of file QwDatabase.h.
Referenced by GetVersion(), GetVersionPoint(), QwDatabase(), QwDatabase(), StoreDBVersion(), and ValidateConnection().
|
private |
Definition at line 444 of file QwDatabase.h.
Referenced by GetValidVersion(), QwDatabase(), QwDatabase(), and ValidateConnection().
|
private |
Definition at line 445 of file QwDatabase.h.
Referenced by GetValidVersion(), QwDatabase(), QwDatabase(), and ValidateConnection().
|
private |
Definition at line 446 of file QwDatabase.h.
Referenced by GetValidVersion(), QwDatabase(), QwDatabase(), and ValidateConnection().