/* * genericDB.cc * * Created on: Jun 19, 2013 * Author: nerses@jlab.org */ #include "genericDB.hh" #include #include //using namespace std; /* * Constructor and destructor */ //GenericDB::GenericDB(){ //// cr = new map; //} //GenericDB::~GenericDB(){ //// delete cr; //// cr = 0; //} const int GenericDB::MAX_HIERERCHY_LEVELS = 20; /* * Parse URI and Open the connection to the DB. * Run the query and put acquired info into cr map. */ void GenericDB::addDetector(const char* detector, const char* URI){ std::string uri; // URI of current detector // Verify if the detector group is defined //int idet = det.capacity(); int idet = det.size(); det.push_back(string(detector)); cout<<"idet = "<::iterator it = det.begin(); it != det.end(); ++it) { QString q = "SELECT " "Crate.crateid as crid, Crate.name as crname," "Crate.area as crarea, Crate.rack as crrack," "Crate.location as crlocation, Crate.SN as crSN," "Crate.Function as crFunction, Crate.rocid as crrocid," "Crate.host as crhost, Crate.IP as crIP " "FROM Channel JOIN " "Module ON Channel.moduleid = Module.moduleid," " Crate ON Module.crateid = Crate.crateid " "WHERE (Channel.col_name='hv_chanid' or Channel.col_name='lv_chanid' or Channel.col_name='bias_chanid')" " and system='%1' GROUP BY crid"; // QString q = "SELECT " // "Crate.crateid as crid " // "FROM Channel JOIN " // "Module ON Channel.moduleid = Module.moduleid," // " Crate ON Module.crateid = Crate.crateid " // "WHERE col_name='hv_chanid' and system='%1' GROUP BY crid"; qWarning()<::iterator it=cr.begin(); it != cr.end(); it++ ) { // cout << "Key " << it->first << " , Value is " << it->second << endl; // } return cr; } /* * Get the vector of detectors */ vector GenericDB::getDetectors(){ // cout << "Getting Crates" << endl; // for( map::iterator it=cr.begin(); it != cr.end(); it++ ) { // cout << "Key " << it->first << " , Value is " << it->second << endl; // } return det; } /* * Get the List of Channels and store them in the HVCRATE Crate[] */ map > GenericDB::getChannels(){ map > channels; QSqlQuery query("SELECT " "Crate.crateid as crid, Crate.name as crname," "Crate.area as crarea, Crate.rack as crrack," "Crate.location as crlocation, Crate.SN as crSN," "Crate.Function as crFunction, Crate.rocid as crrocid, " "Module.moduleid as mid, Module.crateid as mcrateid," "Module.slot as mslot, Module.type as mtype, " "Module.SN as mSN, " "Channel.chanid, Channel.moduleid, Channel.name," "Channel.channel, Channel.system, Channel.col_name " "FROM Channel JOIN " "Module ON Channel.moduleid = Module.moduleid, " " Crate ON Module.crateid = Crate.crateid " "WHERE col_name='hv_chanid' or col_name='lv_chanid' or col_name='bias_chanid'"); qWarning()<