ReadDbTable
#include <iostream.h>
#include "StDbManager.hh"
#include "StDbConfigNode.hh"
#include "StDbTable.h"
#include "StDbDefs.hh"
#include "RunLog/daqRunTag.h"
/////////////////////////////////////////////////////////////////////////////
//
// Simple example code that connects to the database
// & reads a specific c-struct of data... This process can
// be "automated" for an ensemble of c-structs in 2 ways (after
//
// mgr->setRequestTime(unsigned int t); // OR
// mgr->setRequestTime(const char* dataTime); // year-mo-dy hr:mi:sc )
//
// 1. Requesting via the ensemble contained within StDbConfigNode
//
// 2. This example: single table request
//
// MyCstruct* c;
//
// StDbConfigNode* node= mgr->initConfig(dbType,dbDomain);
// StDbTable* table=node->addDbTable("myCstructName","myVersion");
// mgr->fetchDbTable(table);
// c = (MyCstruct*)table->GetTable();
//
//
/////////////////////////////////////////////////////////////////////////////
int
main(int argc, char** argv)
{
// Here I will request the daqRunTag table from the database RunLog_daq
//
//->get the singleton manager
//
StDbManager* mgr = StDbManager::Instance();
//
//->set the db enumerations
//
StDbType type = RunLog;
StDbDomain domain = Daq;
//
//-> connect to the db & get an empty container
//
// (Note: To get a full container, one adds a string "key" arguement
// to this same 'initConfig' member function)
//
StDbConfigNode* configNode = mgr->initConfig(type,domain);
//
//-> add a table to the container with descriptor given by Database
//
// (Notes:
// configNode->addTable("daqRunTag"); doesn't get DB-descriptor
// configNode->addDbTable("daqRunTag","aVersion"); gets a specific version
StDbTable* tab1 = configNode->addDbTable("daqRunTag");
//
// set the request time. (need to be only once for an ensemble of tables)
//
mgr->setRequestTime("1999-09-22 00:00:11");
//
// fetch the data & use it.
//
mgr->fetchDbTable(tab1);
daqRunTag* b1 = (daqRunTag*)tab1->GetTable();
cout << endl << " Here are some data associated with this instance of" << endl;
cout << " TableName = " << tab1->getTableName() << endl;
cout << " Run = " << b1->run << endl;
cout << " startTime = " << b1->startTime << endl;
cout << " runType = " << b1->runType << endl;
cout << endl << " Here are some meta data associated with this instance" << endl;
cout << " My Request Time = " << mgr->getDateCheckTime() << endl;
cout << " BeginTime = " << tab1->getBeginDateTime() << endl;
cout << " EndTime = " << tab1->getEndDateTime() << endl;
cout << " version = " << tab1->getVersion() << endl;
cout << " DataBaseType = " << mgr->getDbTypeName(tab1->getDbType())<< endl;
cout << " DataBaseDomain = " << mgr->getDbDomainName(tab1->getDbDomain())<< endl;
}
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.