Particle Identification and Tracking
|
Class to wrap around the sqlite3 interface to deal with making connections to data basese, cleaning up after them etc. More...
#include <sql_handler.h>
Public Member Functions | |
SQL_handler () | |
Constructor. More... | |
~SQL_handler () | |
Destructor. More... | |
void | open_connection (const std::string &db_name) |
Opens the data base connection. More... | |
void | close_connection () |
Closes the connection. More... | |
int | start_comp (int dset_key, int &comp_key, F_TYPE f_type) |
Adds an entry to the comps table, open a transaction, and return the comp_key. More... | |
void | add_mdata (const Md_store &md_store) |
Adds the function specific meta-data to the table. More... | |
void | commit () |
Commits the transactions. More... | |
void | rollback () |
Rolls back the transaction. More... | |
void | make_test_db (std::string fname="") |
Testing structure. More... | |
void | get_comp_mdata (int comp_key, Md_store &md_store, std::string table_name) |
get the meta data for a computation More... | |
Protected Member Functions | |
void | iden_md_fun (const Md_store &md_store) |
void | tracking_md_fun (const Md_store &md_store) |
void | msd_md_fun (const Md_store &md_store) |
void | gofr_md_fun (const Md_store &md_store) |
void | vanHove_md_fun (const Md_store &md_store) |
void | gofr_by_plane_md_fun (const Md_store &md_store) |
void | msd_sweep_md_fun (const Md_store &md_store) |
void | phi6_md_fun (const Md_store &md_store) |
Private Attributes | |
sqlite3 * | db_ |
Pointer to the data base object. More... | |
bool | conn_open_ |
Flag if the connection is open. More... | |
bool | trans_open_ |
Flag if there is an open transaction. More... | |
F_TYPE | trans_type_ |
Type of the current transaction. More... | |
int | comp_key_ |
The computation key. More... | |
Class to wrap around the sqlite3 interface to deal with making connections to data basese, cleaning up after them etc.
Will have both functions do to specific things, ie add a computation, and a function that eats a string.
SQL_handler::SQL_handler | ( | ) |
Constructor.
Assumes a very specific database layout, see external documentation
SQL_handler::~SQL_handler | ( | ) |
Destructor.
References close_connection().
void SQL_handler::add_mdata | ( | const Md_store & | md_store) |
Adds the function specific meta-data to the table.
References comp_key_, conn_open_, utilities::F_GOFR, utilities::F_GOFR3D, utilities::F_GOFR_BY_PLANE, utilities::F_IDEN, utilities::F_IDEN_AVG, utilities::F_LINK3D, utilities::F_MSD, utilities::F_MSD_SWEEP, utilities::F_NOFUNCTION, utilities::F_PHI6, utilities::F_TRACK_STATS, utilities::F_TRACKING, utilities::F_VANHOVE, utilities::Md_store::get_value(), gofr_by_plane_md_fun(), gofr_md_fun(), iden_md_fun(), msd_md_fun(), msd_sweep_md_fun(), phi6_md_fun(), tracking_md_fun(), trans_open_, trans_type_, and vanHove_md_fun().
Referenced by main(), and test_fun().
void SQL_handler::close_connection | ( | ) |
Closes the connection.
References conn_open_, db_, and err_format().
Referenced by main(), and ~SQL_handler().
void SQL_handler::commit | ( | ) |
Commits the transactions.
If the transaction is not committed before the object is destroyed it will be rolled back. If commit is called with out an open transaction, throws runtime_error.
If successful, resets transaction values
References conn_open_, db_, exec_wrapper(), utilities::F_NOFUNCTION, trans_open_, and trans_type_.
Referenced by main(), and test_fun().
void SQL_handler::get_comp_mdata | ( | int | comp_key, |
Md_store & | md_store, | ||
std::string | table_name | ||
) |
get the meta data for a computation
References utilities::Md_store::add_element(), db_, err_format(), and int_bind().
Referenced by main(), and test_fun().
|
protected |
References db_, err_format(), float_bind(), utilities::Md_store::get_value(), int_bind(), rollback(), and text_bind().
Referenced by add_mdata().
|
protected |
References db_, err_format(), float_bind(), utilities::Md_store::get_value(), int_bind(), rollback(), and text_bind().
Referenced by add_mdata().
|
protected |
References db_, err_format(), float_bind(), utilities::Md_store::get_value(), int_bind(), and rollback().
Referenced by add_mdata().
void SQL_handler::make_test_db | ( | std::string | fname = "" ) |
|
protected |
References db_, err_format(), utilities::Md_store::get_value(), int_bind(), rollback(), and text_bind().
Referenced by add_mdata().
|
protected |
References db_, err_format(), utilities::Md_store::get_value(), int_bind(), and rollback().
Referenced by add_mdata().
void SQL_handler::open_connection | ( | const std::string & | db_name) |
Opens the data base connection.
[in] | db_name | the full path of data base file. |
References conn_open_, and db_.
Referenced by main(), and make_test_db().
|
protected |
References db_, err_format(), float_bind(), utilities::Md_store::get_value(), int_bind(), rollback(), and text_bind().
Referenced by add_mdata().
void SQL_handler::rollback | ( | ) |
Rolls back the transaction.
If there is no connection or transaction open, does nothing.
If successful, resets transaction values
References conn_open_, db_, exec_wrapper(), utilities::F_NOFUNCTION, trans_open_, and trans_type_.
Referenced by gofr_by_plane_md_fun(), gofr_md_fun(), iden_md_fun(), msd_md_fun(), msd_sweep_md_fun(), phi6_md_fun(), tracking_md_fun(), and vanHove_md_fun().
int SQL_handler::start_comp | ( | int | dset_key, |
int & | comp_key, | ||
F_TYPE | f_type | ||
) |
Adds an entry to the comps table, open a transaction, and return the comp_key.
[in] | dset_key | the key of the data set the function is working on |
[out] | comp_key | the key of the computation, taken from the database |
[in] | f_type | the type of computation being done. The guts of this object need to know to handle the meta-data for each function. |
References comp_key_, conn_open_, db_, err_format(), exec_wrapper(), utilities::F_NOFUNCTION, int_bind(), trans_open_, and trans_type_.
Referenced by main(), and test_fun().
|
protected |
References db_, err_format(), float_bind(), utilities::Md_store::get_value(), int_bind(), rollback(), and text_bind().
Referenced by add_mdata().
|
protected |
References db_, err_format(), utilities::Md_store::get_value(), int_bind(), rollback(), and text_bind().
Referenced by add_mdata().
|
private |
The computation key.
Referenced by add_mdata(), and start_comp().
|
private |
Flag if the connection is open.
Referenced by add_mdata(), close_connection(), commit(), open_connection(), rollback(), and start_comp().
|
private |
Pointer to the data base object.
Referenced by close_connection(), commit(), get_comp_mdata(), gofr_by_plane_md_fun(), gofr_md_fun(), iden_md_fun(), make_test_db(), msd_md_fun(), msd_sweep_md_fun(), open_connection(), phi6_md_fun(), rollback(), start_comp(), tracking_md_fun(), and vanHove_md_fun().
|
private |
Flag if there is an open transaction.
Referenced by add_mdata(), commit(), rollback(), and start_comp().
|
private |
Type of the current transaction.
Referenced by add_mdata(), commit(), rollback(), and start_comp().