QwAnalysis
|
A database interface class. More...
#include <QwDatabase.h>
Public Member Functions | |
QwDatabase (const string &major="00", const string &minor="00", const string &point="0000") | |
Simple constructor. More... | |
QwDatabase (QwOptions &options, const string &major="00", const string &minor="00", const string &point="0000") | |
Constructor with QwOptions object. More... | |
virtual | ~QwDatabase () |
Destructor. More... | |
void | SetAccessLevel (string accesslevel) |
Sets the access level flag based on string labels: "off", "ro", "rw". More... | |
Bool_t | AllowsReadAccess () |
Bool_t | AllowsWriteAccess () |
Bool_t | Connect () |
Open a connection to the database using the predefined parameters. More... | |
void | Disconnect () |
Bool_t | Connected () |
const string | GetServerVersion () |
void | ProcessOptions (QwOptions &options) |
Processes the options contained in the QwOptions object. More... | |
void | ProcessOptions (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. More... | |
mysqlpp::Query | Query (const char *qstr=0) |
mysqlpp::Query | Query (const std::string &qstr) |
const string | GetVersion () |
const string | GetVersionMajor () |
Return a full version string for the DB schema. More... | |
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. More... | |
Private Types | |
enum | EQwDBAccessLevel { kQwDatabaseOff, kQwDatabaseReadOnly, kQwDatabaseReadWrite } |
Private Member Functions | |
Bool_t | ValidateConnection () |
Checks that given connection parameters result in a valid connection. More... | |
bool | StoreDBVersion () |
Retrieve database schema version information from database. More... | |
QwDatabase (const QwDatabase &rhs) | |
Copy Constructor (not implemented) More... | |
QwDatabase & | operator= (const QwDatabase &rhs) |
Assignment operator (not implemented) More... | |
Private Attributes | |
EQwDBAccessLevel | fAccessLevel |
Access level of the database instance. More... | |
string | fDatabase |
Name of database to connect to. More... | |
string | fDBServer |
Name of server carrying DB to connect to. More... | |
string | fDBUsername |
Name of account to connect to DB server with. More... | |
string | fDBPassword |
DB account password. More... | |
UInt_t | fDBPortNumber |
Port number to connect to on server (mysql default port is 3306) More... | |
Bool_t | fValidConnection |
True if a valid connection was established using defined connection information. More... | |
string | fVersionMajor |
Major version number of current DB schema. More... | |
string | fVersionMinor |
Minor version number of current DB schema. More... | |
string | fVersionPoint |
Point version number of current DB schema. More... | |
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 45 of file QwDatabase.h.
|
private |
Enumerator | |
---|---|
kQwDatabaseOff | |
kQwDatabaseReadOnly | |
kQwDatabaseReadWrite |
Definition at line 79 of file QwDatabase.h.
QwDatabase::QwDatabase | ( | const string & | major = "00" , |
const string & | minor = "00" , |
||
const string & | point = "0000" |
||
) |
Simple constructor.
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 53 of file QwDatabase.cc.
References QwLog::endl(), fAccessLevel, fDatabase, fDBPassword, fDBPortNumber, fDBServer, fDBUsername, fValidConnection, fVersionMajor, fVersionMinor, fVersionPoint, kQwDatabaseOff, ProcessOptions(), and QwDebug.
|
virtual |
Destructor.
The destructor says "Good-bye World!"
Definition at line 72 of file QwDatabase.cc.
References Disconnect(), QwLog::endl(), and QwDebug.
|
private |
Copy Constructor (not implemented)
|
inline |
Definition at line 55 of file QwDatabase.h.
References fAccessLevel, kQwDatabaseReadOnly, and kQwDatabaseReadWrite.
Referenced by QwParityDB::SetupOneRun().
|
inline |
Definition at line 56 of file QwDatabase.h.
References fAccessLevel, and kQwDatabaseReadWrite.
Referenced by main().
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 175 of file QwDatabase.cc.
References QwLog::endl(), fAccessLevel, fDatabase, fDBPassword, fDBPortNumber, fDBServer, fDBUsername, fValidConnection, kQwDatabaseOff, QwError, and ValidateConnection().
Referenced by QwEPICSEvent::FillDB(), QwRegression::FillDB(), QwBlinder::FillDB(), QwMainCerenkovDetector::FillDB(), QwBeamLine::FillDB(), QwIntegratedRaster::FillDB(), QwHelicity::FillDB(), QwLumi::FillDB(), QwBeamMod::FillDB_MPS(), QwBlinder::FillErrDB(), QwMainCerenkovDetector::FillErrDB(), QwBeamLine::FillErrDB(), QwIntegratedRaster::FillErrDB(), QwLumi::FillErrDB(), QwParityDB::FillParameterFiles(), QwEPICSEvent::FillSlowControlsData(), QwEPICSEvent::FillSlowControlsSettings(), QwEPICSEvent::FillSlowControlsStrigs(), QwBlinder::ReadSeed(), QwParityDB::SetAnalysisID(), QwParityDB::SetRunID(), QwParityDB::SetRunletID(), QwParityDB::SetRunNumber(), QwParityDB::StoreErrorCodeIDs(), QwParityDB::StoreLumiDetectorIDs(), QwParityDB::StoreMainDetectorIDs(), QwParityDB::StoreMeasurementIDs(), QwParityDB::StoreMonitorIDs(), QwParityDB::StoreSlowControlDetectorIDs(), QwBlinder::WriteChecksum(), and QwBlinder::WriteTestValues().
|
inline |
Definition at line 60 of file QwDatabase.h.
Referenced by QwParityDB::~QwParityDB().
|
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 209 of file QwDatabase.cc.
References QwOptions::AddOptions().
Referenced by QwOptions::DefineOptions().
|
inline |
Definition at line 59 of file QwDatabase.h.
Referenced by QwEPICSEvent::FillDB(), QwRegression::FillDB(), QwBlinder::FillDB(), QwMainCerenkovDetector::FillDB(), QwBeamLine::FillDB(), QwIntegratedRaster::FillDB(), QwHelicity::FillDB(), QwLumi::FillDB(), QwBeamMod::FillDB_MPS(), QwBlinder::FillErrDB(), QwMainCerenkovDetector::FillErrDB(), QwBeamLine::FillErrDB(), QwIntegratedRaster::FillErrDB(), QwLumi::FillErrDB(), QwParityDB::FillParameterFiles(), QwEPICSEvent::FillSlowControlsData(), QwEPICSEvent::FillSlowControlsSettings(), QwEPICSEvent::FillSlowControlsStrigs(), QwBlinder::ReadSeed(), QwParityDB::SetAnalysisID(), QwParityDB::SetRunID(), QwParityDB::SetRunletID(), QwParityDB::SetRunNumber(), StoreDBVersion(), QwParityDB::StoreErrorCodeIDs(), QwParityDB::StoreLumiDetectorIDs(), QwParityDB::StoreMainDetectorIDs(), QwParityDB::StoreMeasurementIDs(), QwParityDB::StoreMonitorIDs(), QwParityDB::StoreSlowControlDetectorIDs(), QwBlinder::WriteChecksum(), QwBlinder::WriteTestValues(), ~QwDatabase(), and QwParityDB::~QwParityDB().
|
inline |
Definition at line 61 of file QwDatabase.h.
Referenced by PrintServerInfo().
const string QwDatabase::GetValidVersion | ( | ) |
Definition at line 309 of file QwDatabase.cc.
References kValidVersionMajor, kValidVersionMinor, and kValidVersionPoint.
Referenced by ValidateConnection().
const string QwDatabase::GetVersion | ( | ) |
Definition at line 304 of file QwDatabase.cc.
References fVersionMajor, fVersionMinor, and fVersionPoint.
Referenced by main(), and ValidateConnection().
|
inline |
Return a full version string for the DB schema.
Definition at line 71 of file QwDatabase.h.
References fVersionMajor.
|
inline |
Definition at line 72 of file QwDatabase.h.
References fVersionMinor.
|
inline |
Definition at line 73 of file QwDatabase.h.
References fVersionPoint.
|
private |
Assignment operator (not implemented)
void QwDatabase::PrintServerInfo | ( | ) |
This function prints the server information.
Definition at line 283 of file QwDatabase.cc.
References BLUE, BOLD, fDatabase, fDBPortNumber, fDBServer, fDBUsername, fValidConnection, GetServerVersion(), NORMAL, and RED.
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 225 of file QwDatabase.cc.
References QwLog::endl(), fAccessLevel, fDatabase, fDBPassword, fDBPortNumber, fDBServer, fDBUsername, QwOptions::GetValue(), QwOptions::HasValue(), kQwDatabaseOff, QwWarning, and SetAccessLevel().
Referenced by QwDatabase().
void QwDatabase::ProcessOptions | ( | 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 254 of file QwDatabase.cc.
References fDatabase, fDBPassword, fDBPortNumber, fDBServer, fDBUsername, and SetAccessLevel().
|
inline |
Definition at line 66 of file QwDatabase.h.
Referenced by QwEPICSEvent::FillDB(), QwRegression::FillDB(), QwBlinder::FillDB(), QwMainCerenkovDetector::FillDB(), QwBeamLine::FillDB(), QwIntegratedRaster::FillDB(), QwHelicity::FillDB(), QwLumi::FillDB(), QwBeamMod::FillDB_MPS(), QwBlinder::FillErrDB(), QwMainCerenkovDetector::FillErrDB(), QwBeamLine::FillErrDB(), QwIntegratedRaster::FillErrDB(), QwLumi::FillErrDB(), QwParityDB::FillParameterFiles(), QwEPICSEvent::FillSlowControlsData(), QwEPICSEvent::FillSlowControlsSettings(), QwEPICSEvent::FillSlowControlsStrigs(), QwBlinder::ReadSeed(), QwParityDB::SetAnalysisID(), QwParityDB::SetRunID(), QwParityDB::SetRunletID(), QwParityDB::SetRunNumber(), StoreDBVersion(), QwParityDB::StoreErrorCodeIDs(), QwParityDB::StoreLumiDetectorIDs(), QwParityDB::StoreMainDetectorIDs(), QwParityDB::StoreMeasurementIDs(), QwParityDB::StoreMonitorIDs(), QwParityDB::StoreSlowControlDetectorIDs(), QwBlinder::WriteChecksum(), and QwBlinder::WriteTestValues().
|
inline |
Definition at line 67 of file QwDatabase.h.
void QwDatabase::SetAccessLevel | ( | string | accesslevel | ) |
Sets the access level flag based on string labels: "off", "ro", "rw".
Definition at line 264 of file QwDatabase.cc.
References QwLog::endl(), fAccessLevel, kQwDatabaseOff, kQwDatabaseReadOnly, kQwDatabaseReadWrite, and QwWarning.
Referenced by ProcessOptions().
|
private |
Retrieve database schema version information from database.
Definition at line 318 of file QwDatabase.cc.
References Disconnect(), QwLog::endl(), fVersionMajor, fVersionMinor, fVersionPoint, Query(), QwDebug, and QwError.
Referenced by ValidateConnection().
|
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 84 of file QwDatabase.cc.
References Qw::e, QwLog::endl(), fAccessLevel, fDatabase, fDBPassword, fDBPortNumber, fDBServer, fDBUsername, fValidConnection, fVersionMajor, fVersionMinor, fVersionPoint, GetValidVersion(), GetVersion(), kQwDatabaseOff, kQwDatabaseReadWrite, kValidVersionMajor, kValidVersionMinor, kValidVersionPoint, QwDebug, QwError, QwMessage, QwWarning, and StoreDBVersion().
Referenced by Connect().
|
private |
Access level of the database instance.
Definition at line 91 of file QwDatabase.h.
Referenced by AllowsReadAccess(), AllowsWriteAccess(), Connect(), ProcessOptions(), QwDatabase(), SetAccessLevel(), and ValidateConnection().
|
private |
Name of database to connect to.
Definition at line 93 of file QwDatabase.h.
Referenced by Connect(), PrintServerInfo(), ProcessOptions(), QwDatabase(), and ValidateConnection().
|
private |
DB account password.
Definition at line 96 of file QwDatabase.h.
Referenced by Connect(), ProcessOptions(), QwDatabase(), and ValidateConnection().
|
private |
Port number to connect to on server (mysql default port is 3306)
Definition at line 97 of file QwDatabase.h.
Referenced by Connect(), PrintServerInfo(), ProcessOptions(), QwDatabase(), and ValidateConnection().
|
private |
Name of server carrying DB to connect to.
Definition at line 94 of file QwDatabase.h.
Referenced by Connect(), PrintServerInfo(), ProcessOptions(), QwDatabase(), and ValidateConnection().
|
private |
Name of account to connect to DB server with.
Definition at line 95 of file QwDatabase.h.
Referenced by Connect(), PrintServerInfo(), ProcessOptions(), QwDatabase(), and ValidateConnection().
|
private |
True if a valid connection was established using defined connection information.
Definition at line 98 of file QwDatabase.h.
Referenced by Connect(), PrintServerInfo(), QwDatabase(), and ValidateConnection().
|
private |
Major version number of current DB schema.
Definition at line 100 of file QwDatabase.h.
Referenced by GetVersion(), GetVersionMajor(), QwDatabase(), StoreDBVersion(), and ValidateConnection().
|
private |
Minor version number of current DB schema.
Definition at line 101 of file QwDatabase.h.
Referenced by GetVersion(), GetVersionMinor(), QwDatabase(), StoreDBVersion(), and ValidateConnection().
|
private |
Point version number of current DB schema.
Definition at line 102 of file QwDatabase.h.
Referenced by GetVersion(), GetVersionPoint(), QwDatabase(), StoreDBVersion(), and ValidateConnection().
|
private |
Definition at line 103 of file QwDatabase.h.
Referenced by GetValidVersion(), and ValidateConnection().
|
private |
Definition at line 104 of file QwDatabase.h.
Referenced by GetValidVersion(), and ValidateConnection().
|
private |
Definition at line 105 of file QwDatabase.h.
Referenced by GetValidVersion(), and ValidateConnection().