Particle Identification and Tracking
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
utilities::SQL_handler Class Reference

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>

+ Collaboration diagram for utilities::SQL_handler:

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

SQL_handler::SQL_handler ( )

Constructor.

Assumes a very specific database layout, see external documentation

SQL_handler::~SQL_handler ( )

Destructor.

References close_connection().

Member Function Documentation

void SQL_handler::add_mdata ( const Md_store md_store)
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().

void SQL_handler::gofr_by_plane_md_fun ( const Md_store md_store)
protected
void SQL_handler::gofr_md_fun ( const Md_store md_store)
protected
void SQL_handler::iden_md_fun ( const Md_store md_store)
protected
void SQL_handler::make_test_db ( std::string  fname = "")

Testing structure.

References db_, exec_wrapper(), and open_connection().

Referenced by main().

void SQL_handler::msd_md_fun ( const Md_store md_store)
protected
void SQL_handler::msd_sweep_md_fun ( const Md_store md_store)
protected
void SQL_handler::open_connection ( const std::string &  db_name)

Opens the data base connection.

Parameters
[in]db_namethe full path of data base file.

References conn_open_, and db_.

Referenced by main(), and make_test_db().

void SQL_handler::phi6_md_fun ( const Md_store md_store)
protected
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.

Parameters
[in]dset_keythe key of the data set the function is working on
[out]comp_keythe key of the computation, taken from the database
[in]f_typethe type of computation being done. The guts of this object need to know to handle the meta-data for each function.
Returns
the computation key

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().

void SQL_handler::tracking_md_fun ( const Md_store md_store)
protected
void SQL_handler::vanHove_md_fun ( const Md_store md_store)
protected

Member Data Documentation

int utilities::SQL_handler::comp_key_
private

The computation key.

Referenced by add_mdata(), and start_comp().

bool utilities::SQL_handler::conn_open_
private

Flag if the connection is open.

Referenced by add_mdata(), close_connection(), commit(), open_connection(), rollback(), and start_comp().

sqlite3* utilities::SQL_handler::db_
private
bool utilities::SQL_handler::trans_open_
private

Flag if there is an open transaction.

Referenced by add_mdata(), commit(), rollback(), and start_comp().

F_TYPE utilities::SQL_handler::trans_type_
private

Type of the current transaction.

Referenced by add_mdata(), commit(), rollback(), and start_comp().


The documentation for this class was generated from the following files: