SctArchiving::IOManagerDB Class Reference

This IOManager reads from and writes to a database. More...

#include <IOManagerDB.h>

Inheritance diagram for SctArchiving::IOManagerDB:

Inheritance graph
[legend]
Collaboration diagram for SctArchiving::IOManagerDB:

Collaboration graph
[legend]

Public Member Functions

virtual shared_ptr< Sct::Serializableread (const string &name, const Sct::IOParams *params=0) const
 read using appropriate streamers
virtual ~IOManagerDB ()
virtual std::string status () const
 get some status information
virtual void addRun (unsigned long runNumber, bool trash) const
 Add a run - gets data set identifier from getDataSetID.
virtual void addTest (const TestData &testdata, bool alsoAddScans) const
 Add a test.
virtual void addScan (const TestData &testdata, unsigned scanNumber) const
 Add a scan.
virtual void addModule (const std::string &layerName, const std::string &LMTnr, const std::string &poistionNumber, const std::string &moduleNumber) const
 Add a module.
virtual void addRawDataRecord (const std::string &moduleId, const std::string &scanId) const
 Add module-scan combination raw data table.
virtual void addRawDataBlob (const std::string &moduleId, const std::string &scanId, const char *chBuf, const long bufSize) const
 Add binary data to raw data table.
virtual std::string getRawDataBlob (const std::string &moduleId, const std::string &scanId) const
 Get binary data from raw data table.
virtual std::string getDataSetName () const
 get string identifying data set e.g.
virtual void setDataSetName (const std::string &dataSetName)
 set the string identifying data set e.g.
IOManager stuff
write using default streamers

virtual void write (const Sct::Serializable &ob, const Sct::IOParams *params=0) const
 Write an object.
methods for getting table row identifiers
Use strings for now, since we are always communicating with sql

Return empty string if not found!

Uses the current DataSetName

std::string getDataSetID () const
std::string getTestTypeID (const std::string &testName) const
std::string getRunID (const unsigned runNumber) const
std::string getTestID (const std::string &runId, const unsigned startScanNumber) const
std::string getScanID (const std::string &testId, const unsigned scanNumber) const
std::string getLayerID (const std::string &layerName) const
std::string getRowID (const std::string &layerId, const std::string &LMTnr) const
std::string getPositionID (const std::string &rowId, const std::string &positionNumber) const
std::string getModuleID (const std::string &moduleNumber) const

Static Public Member Functions

static IOManagerDBinstance ()
 retrieve access to singleton
static std::string convertToMysqlDateTimeFormat (const std::string &isotime)
 conversion just removes 'T' from isotime

Private Member Functions

void checkForMySqlErrors (const string &msg, const string &file, int line) const
 throw MysqlException if there is an error in the mysql object
void checkForMySqlErrors (const string &msg, const string &query, const string &file, int line) const
 throw MysqlException if there is an error in the mysql object - listing query
 IOManagerDB ()
 constructor.
boost::shared_ptr< MYSQL_RES > getResult () const
 gets result, using msql_free_result in deleter
std::string executeQueryReturnID (std::string query) const
 utility method for getting single id Or more precise, this method returns the result of a query deisgned to return one record (row) and one field (column).
void executeQuery (std::string query) const

Static Private Member Functions

static const SctData::ResultHeadergetHeader (const Sct::Serializable &ob)
 get the header from a TestResult or ScanResult
static std::string getTable (const Sct::Serializable &ob)
 find the name of the table which the ob should to into.

Private Attributes

boost::shared_ptr< ZlibStringCompressorm_compressor
 keep a string compressor handy to zip and unzip BLOB data.
MYSQL * m_mysql
 the main MYSQL object
std::string m_dataSetName
 name of data set - e.g.
boost::recursive_mutex timingAccess
 mutex for timing information
unsigned m_nRead
 total number got out of database
unsigned m_nWrite
 total number put into database
unsigned m_nCompress
 # of strings compressed
unsigned m_nDecompress
 # of strings decompressed
unsigned m_nBlobAdd
 # of raw objects added to database
unsigned m_nQueries
 # of raw objects added to database
boost::posix_time::time_duration read_time
 time spent reading from database
boost::posix_time::time_duration write_time
 time spent writing to database
boost::posix_time::time_duration compress_time
 time spent compressing data
boost::posix_time::time_duration decompress_time
 time spent decompressing data
boost::posix_time::time_duration blob_add_time
 time spent adding raw data blobs to db
boost::posix_time::time_duration query_time
 time spent adding raw data blobs to db
boost::posix_time::time_duration ostream_time
 time spent adding raw data blobs to db
boost::posix_time::time_duration istream_time
 time spent adding raw data blobs to db

Static Private Attributes

static IOManagerDBs_man
 pointer to singleton

Data Structures

class  MySqlFreeResultDeleter

Detailed Description

This IOManager reads from and writes to a database.

It is expected to be used in archival, and so also makes use of streamer versioning by inheriting from IOManagerStreamerVersioned. Uses a mysql back-end.

Definition at line 36 of file IOManagerDB.h.


Constructor & Destructor Documentation

SctArchiving::IOManagerDB::IOManagerDB  )  [private]
 

constructor.

Definition at line 66 of file IOManagerDB.cpp.

References checkForMySqlErrors(), m_compressor, and m_mysql.

Referenced by instance().

Here is the call graph for this function:


Member Function Documentation

void SctArchiving::IOManagerDB::addModule const std::string &  layerName,
const std::string &  LMTnr,
const std::string &  poistionNumber,
const std::string &  moduleNumber
const [virtual]
 

Add a module.

Definition at line 678 of file IOManagerDB.cpp.

References executeQuery(), getLayerID(), getPositionID(), getRowID(), and m_mysql.

Referenced by write().

Here is the call graph for this function:

void SctArchiving::IOManagerDB::addRawDataBlob const std::string &  moduleId,
const std::string &  scanId,
const char *  chBuf,
const long  bufSize
const [virtual]
 

Add binary data to raw data table.

Definition at line 715 of file IOManagerDB.cpp.

References checkForMySqlErrors(), and m_mysql.

Here is the call graph for this function:

void SctArchiving::IOManagerDB::addRawDataRecord const std::string &  moduleId,
const std::string &  scanId
const [virtual]
 

Add module-scan combination raw data table.

Definition at line 699 of file IOManagerDB.cpp.

References checkForMySqlErrors(), and m_mysql.

Here is the call graph for this function:

void SctArchiving::IOManagerDB::addRun unsigned long  runNumber,
bool  trash
const [virtual]
 

Add a run - gets data set identifier from getDataSetID.

Definition at line 623 of file IOManagerDB.cpp.

References executeQuery(), getDataSetID(), and m_mysql.

Referenced by write().

Here is the call graph for this function:

void SctArchiving::IOManagerDB::addScan const TestData testdata,
unsigned  scanNumber
const [virtual]
 

Add a scan.

Identifies correct Test from the run# and the 1st scan number.

Definition at line 662 of file IOManagerDB.cpp.

References executeQuery(), getRunID(), getTestID(), m_mysql, TestData::runNumber, and TestData::startScanNumber.

Referenced by addTest().

Here is the call graph for this function:

void SctArchiving::IOManagerDB::addTest const TestData testdata,
bool  alsoAddScans
const [virtual]
 

Add a test.

Parameters:
alsoAddScans if this is true, it will loop over the scans in the test adding them too

Definition at line 637 of file IOManagerDB.cpp.

References addScan(), convertToMysqlDateTimeFormat(), TestData::endTime, executeQuery(), getRunID(), getTestTypeID(), m_mysql, TestData::nScans, TestData::runNumber, TestData::startScanNumber, TestData::startTime, and TestData::testName.

Referenced by write().

Here is the call graph for this function:

void SctArchiving::IOManagerDB::checkForMySqlErrors const string &  msg,
const string &  query,
const string &  file,
int  line
const [private]
 

throw MysqlException if there is an error in the mysql object - listing query

Definition at line 49 of file IOManagerDB.cpp.

References m_mysql.

void SctArchiving::IOManagerDB::checkForMySqlErrors const string &  msg,
const string &  file,
int  line
const [private]
 

throw MysqlException if there is an error in the mysql object

Definition at line 39 of file IOManagerDB.cpp.

References m_mysql.

Referenced by addRawDataBlob(), addRawDataRecord(), executeQuery(), executeQueryReturnID(), getRawDataBlob(), getResult(), and IOManagerDB().

std::string SctArchiving::IOManagerDB::convertToMysqlDateTimeFormat const std::string &  isotime  )  [static]
 

conversion just removes 'T' from isotime

Definition at line 521 of file IOManagerDB.cpp.

Referenced by addTest().

std::string SctArchiving::IOManagerDB::executeQueryReturnID std::string  query  )  const [private]
 

utility method for getting single id Or more precise, this method returns the result of a query deisgned to return one record (row) and one field (column).

An exeption is raised if the query returns 0 or more than 1 records. Otherwise the method returns the contents of the first field, other fields are ignored.

Definition at line 854 of file IOManagerDB.cpp.

References checkForMySqlErrors(), executeQuery(), and getResult().

Referenced by getDataSetID(), getLayerID(), getModuleID(), getPositionID(), getRowID(), getRunID(), getScanID(), getTestID(), getTestTypeID(), and read().

Here is the call graph for this function:

std::string SctArchiving::IOManagerDB::getDataSetName  )  const [virtual]
 

get string identifying data set e.g.

Barrel3_Cold_Oxford

Definition at line 543 of file IOManagerDB.cpp.

References m_dataSetName.

Referenced by getDataSetID(), read(), and write().

const SctData::ResultHeader & SctArchiving::IOManagerDB::getHeader const Sct::Serializable ob  )  [static, private]
 

get the header from a TestResult or ScanResult

Definition at line 154 of file IOManagerDB.cpp.

References Sct::Streamable::getClassName().

Here is the call graph for this function:

std::string SctArchiving::IOManagerDB::getRawDataBlob const std::string &  moduleId,
const std::string &  scanId
const [virtual]
 

Get binary data from raw data table.

Definition at line 757 of file IOManagerDB.cpp.

References checkForMySqlErrors(), and m_mysql.

Referenced by read().

Here is the call graph for this function:

boost::shared_ptr< MYSQL_RES > SctArchiving::IOManagerDB::getResult  )  const [private]
 

gets result, using msql_free_result in deleter

Definition at line 868 of file IOManagerDB.cpp.

References checkForMySqlErrors(), and m_mysql.

Referenced by executeQueryReturnID().

Here is the call graph for this function:

string SctArchiving::IOManagerDB::getTable const Sct::Serializable ob  )  [static, private]
 

find the name of the table which the ob should to into.

Definition at line 174 of file IOManagerDB.cpp.

IOManagerDB & SctArchiving::IOManagerDB::instance  )  [static]
 

retrieve access to singleton

Definition at line 108 of file IOManagerDB.cpp.

References IOManagerDB(), and s_man.

Here is the call graph for this function:

boost::shared_ptr< Serializable > SctArchiving::IOManagerDB::read const string &  name,
const Sct::IOParams params = 0
const [virtual]
 

read using appropriate streamers

Implements Sct::IOManager.

Definition at line 351 of file IOManagerDB.cpp.

References decompress_time, executeQueryReturnID(), Sct::IOName::getClassName(), getDataSetName(), getModuleID(), Sct::Archive::IOManagerStreamerVersioned::getMutex(), getRawDataBlob(), Sct::Archive::IOManagerStreamerVersioned::getReadVersionMap(), getRunID(), getScanID(), getTestID(), Sct::IOName::getUniqueID(), istream_time, m_compressor, m_nDecompress, m_nRead, read_time, Sct::Archive::IOManagerStreamerVersioned::readImpl(), Sct::Archive::IOManagerStreamerVersioned::setReadMode(), and timingAccess.

Here is the call graph for this function:

void SctArchiving::IOManagerDB::setDataSetName const std::string &  dataSetName  )  [virtual]
 

set the string identifying data set e.g.

Barrel3_Cold_Oxford

Definition at line 539 of file IOManagerDB.cpp.

References m_dataSetName.

std::string SctArchiving::IOManagerDB::status  )  const [virtual]
 

get some status information

Implements Sct::Archive::IOManagerArchive.

Definition at line 116 of file IOManagerDB.cpp.

References m_compressor.

void SctArchiving::IOManagerDB::write const Sct::Serializable ob,
const Sct::IOParams params = 0
const [virtual]
 

Write an object.

Parameters:
ob The Serializable to write
params A backend specific sub-class of IOParams.
Exceptions:
IoException if there is a problem with the I/O

Implements Sct::IOManager.

Definition at line 180 of file IOManagerDB.cpp.

References addModule(), addRun(), addTest(), Sct::Streamable::getClassName(), getDataSetName(), getModuleID(), Sct::Archive::IOManagerStreamerVersioned::getMutex(), getRunID(), getTestID(), Sct::Serializable::getUniqueID(), ostream_time, Sct::Archive::IOManagerStreamerVersioned::setReadMode(), timingAccess, and Sct::Archive::IOManagerStreamerVersioned::writeImpl().

Here is the call graph for this function:


Field Documentation

boost::posix_time::time_duration SctArchiving::IOManagerDB::blob_add_time [mutable, private]
 

time spent adding raw data blobs to db

Definition at line 194 of file IOManagerDB.h.

boost::posix_time::time_duration SctArchiving::IOManagerDB::compress_time [mutable, private]
 

time spent compressing data

Definition at line 192 of file IOManagerDB.h.

boost::posix_time::time_duration SctArchiving::IOManagerDB::decompress_time [mutable, private]
 

time spent decompressing data

Definition at line 193 of file IOManagerDB.h.

Referenced by read().

boost::posix_time::time_duration SctArchiving::IOManagerDB::istream_time [mutable, private]
 

time spent adding raw data blobs to db

Definition at line 197 of file IOManagerDB.h.

Referenced by read().

boost::shared_ptr<ZlibStringCompressor> SctArchiving::IOManagerDB::m_compressor [private]
 

keep a string compressor handy to zip and unzip BLOB data.

Definition at line 147 of file IOManagerDB.h.

Referenced by IOManagerDB(), read(), and status().

std::string SctArchiving::IOManagerDB::m_dataSetName [private]
 

name of data set - e.g.

barrel3ColdAtOxford

Definition at line 172 of file IOManagerDB.h.

Referenced by getDataSetName(), and setDataSetName().

MYSQL* SctArchiving::IOManagerDB::m_mysql [private]
 

the main MYSQL object

Definition at line 150 of file IOManagerDB.h.

Referenced by addModule(), addRawDataBlob(), addRawDataRecord(), addRun(), addScan(), addTest(), checkForMySqlErrors(), executeQuery(), getRawDataBlob(), getResult(), IOManagerDB(), and ~IOManagerDB().

unsigned SctArchiving::IOManagerDB::m_nBlobAdd [mutable, private]
 

# of raw objects added to database

Definition at line 187 of file IOManagerDB.h.

unsigned SctArchiving::IOManagerDB::m_nCompress [mutable, private]
 

# of strings compressed

Definition at line 185 of file IOManagerDB.h.

unsigned SctArchiving::IOManagerDB::m_nDecompress [mutable, private]
 

# of strings decompressed

Definition at line 186 of file IOManagerDB.h.

Referenced by read().

unsigned SctArchiving::IOManagerDB::m_nQueries [mutable, private]
 

# of raw objects added to database

Definition at line 188 of file IOManagerDB.h.

Referenced by executeQuery().

unsigned SctArchiving::IOManagerDB::m_nRead [mutable, private]
 

total number got out of database

Definition at line 183 of file IOManagerDB.h.

Referenced by read().

unsigned SctArchiving::IOManagerDB::m_nWrite [mutable, private]
 

total number put into database

Definition at line 184 of file IOManagerDB.h.

boost::posix_time::time_duration SctArchiving::IOManagerDB::ostream_time [mutable, private]
 

time spent adding raw data blobs to db

Definition at line 196 of file IOManagerDB.h.

Referenced by write().

boost::posix_time::time_duration SctArchiving::IOManagerDB::query_time [mutable, private]
 

time spent adding raw data blobs to db

Definition at line 195 of file IOManagerDB.h.

Referenced by executeQuery().

boost::posix_time::time_duration SctArchiving::IOManagerDB::read_time [mutable, private]
 

time spent reading from database

Definition at line 190 of file IOManagerDB.h.

Referenced by read().

IOManagerDB * SctArchiving::IOManagerDB::s_man [static, private]
 

pointer to singleton

Definition at line 143 of file IOManagerDB.h.

Referenced by instance().

boost::recursive_mutex SctArchiving::IOManagerDB::timingAccess [mutable, private]
 

mutex for timing information

Definition at line 181 of file IOManagerDB.h.

Referenced by executeQuery(), read(), and write().

boost::posix_time::time_duration SctArchiving::IOManagerDB::write_time [mutable, private]
 

time spent writing to database

Definition at line 191 of file IOManagerDB.h.


The documentation for this class was generated from the following files:
Generated on Mon Feb 6 14:05:10 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6