43 #include "StDbLib/StDbManager.hh"
44 #include "StDbBroker.h"
45 #include "StDbLib/StDbDefs.hh"
46 #include "StDbLib/StDbConfigNode.hh"
47 #include "StDbLib/StDbTable.h"
48 #include "StDbLib/StDbTableDescriptor.h"
49 #include "StMessMgr.h"
53 extern "C" void * DbRead(
unsigned int *nRows,
54 unsigned int *datetime,
55 const char * tableName,
56 const char * structName,
58 unsigned int sizeOfStruct,
61 const char* tableVersion)
69 char currentDateTime[20];
72 sprintf(currentDateTime,
"%.8d",(
int)datetime[0]);
73 sprintf(time,
"%.6d",(
int)datetime[1]);
74 strcat(currentDateTime,time);
76 currentDateTime[19]=
'\0';
77 currentDateTime[18]=currentDateTime[13];
78 currentDateTime[17]=currentDateTime[12];
79 currentDateTime[16]=
':';
80 currentDateTime[15]=currentDateTime[11];
81 currentDateTime[14]=currentDateTime[10];
82 currentDateTime[13]=
':';
83 currentDateTime[12]=currentDateTime[9];
84 currentDateTime[11]=currentDateTime[8];
85 currentDateTime[10]=
' ';
86 currentDateTime[9]=currentDateTime[7];
87 currentDateTime[8]=currentDateTime[6];
88 currentDateTime[7]=
'-';
89 currentDateTime[6]=currentDateTime[5];
90 currentDateTime[5]=currentDateTime[4];
91 currentDateTime[4]=
'-';
103 if(!tableVersion)strcpy((
char*)version,
"default");
105 strcpy((
char*)dbType,
"TestScheme");
106 strcpy((
char*)dbDomain,
"Star");
107 type = mgr->getDbType(dbType);
108 domain = mgr->getDbDomain(dbDomain);
112 if(!mgr->getDataBaseInfo(database, atype, adomain)){
113 LOG_ERROR <<
"StDbManager:: Database specified incorrectly" << endm;
118 type = mgr->getDbType(atype);
119 domain = mgr->getDbDomain(adomain);
126 StDbTable* mtable=node->addDbTable(tableName,version);
140 mgr->setRequestTime(currentDateTime);
141 mgr->fetchDbTable(mtable);
144 if (mtable->GetTable()==NULL)
150 *nRows = mtable->GetNRows();
161 strncpy(row,mtable->getBeginDateTime(),19); row[19] =
'\0';
163 strncpy(validFrom,row,19);validFrom[19]=
'\0';
166 for(i3=0;i3<3;i3++,++ic) {
167 for(i2=0;i2<2;i2++,++ic) {
172 latestDirTime = atoi(temps);
176 strncpy(temps,validFrom,10);
183 latestDirDate = atoi(temps);
189 strncpy(row,mtable->getEndDateTime(),19); row[19] =
'\0';
190 strncpy(validTo,row,19);validTo[19]=
'\0';
193 for(i3=0;i3<3;i3++,++ic) {
194 for(i2=0;i2<2;i2++,++ic) {
199 nextDirTime = atoi(temps);
202 strncpy(temps,validTo,10);
209 nextDirDate = atoi(temps);
211 datetime[0] = latestDirDate;
212 datetime[1] = latestDirTime;
213 datetime[2] = nextDirDate;
214 datetime[3] = nextDirTime;
216 if (datetime[2]==19691231) datetime[2]=20380101;
218 void*
data = mtable->GetTableCpy();
void version(std::ostream &os=std::cout)
print HepMC version
static StDbManager * Instance()
strdup(..) is not ANSI