StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
setHVsys.C
1 // writes eemcHVsys to online-DB
2 //
3 #include "StDbManager.hh"
4 #include "StDbManager.hh"
5 #include "StDbConfigNode.hh"
6 #include "StDbTable.h"
7 #include "StDbXmlReader.h"
8 #include "StDbXmlWriter.h"
9 #include "StDbElementIndex.hh"
10 
11 #include <time.h>
12 #include <stdio.h>
13 #include <assert.h>
14 #include <string.h>
15 
16 #include "kretDbBlobS.hh"
17 //---------------------------------------------------------------------
18 //---------------------------------------------------------------------
19 //---------------------------------------------------------------------
20 int main() {
21  //VerA/online/ETOW
22 
23  StDbManager* mgr = StDbManager::Instance(); //addDbType, addDbDomain
24  StDbConfigNode* nodeHead = mgr->initConfig(dbConditions,dbEemc,"VerA");
25  assert(nodeHead); printf("node found 1\n");
26 
27  StDbConfigNode* nodeOnl = nodeHead->findConfigNode("online");
28  assert(nodeOnl); printf("node found 2\n");
29 
30  printf("access DB table ...");
31  StDbTable * tab;
32  tab = nodeOnl->addDbTable("ETOW");
33  int nrows;
34  int* elist;
35  if(tab->GetNRows()<=0) {
36  printf("JB: FAILED : tab->GetNRows()=%d\n",tab->GetNRows()); return 0;
37  }
38  elist = tab->getElementID(nrows);
39  printf("nrows=%d, elis=%d\n", nrows,*elist);
40 
41 
42  // fill something in c-structs
43  kretDbBlobS blob;
44  strncpy(blob.comment,"comJ1 AA",KRETDbMaxComment);
45  strncpy(blob.dataS,"bodyJ1 AA",KRETmxBlobSlen);
46 
47  tab->SetTable((char*)&blob,1);
48 
49  unsigned int tStore=(unsigned int) time(0);
50 
51  printf("JB: time Store=%s",ctime((const time_t *)&tStore));
52  mgr->setStoreTime(tStore);
53 
54  // printf("JB: WARN - ENTERING BLOCKED\n"); return 1;
55  // if(! mgr->storeAllTables(nodeY)) // not working ???
56 
57  printf("write DB table ...");
58  int ret= mgr->storeDbTable(tab);
59  if( ret){
60  printf("JB: storeTables() done\n");
61  } else {
62  printf("JB: Some problems with storeDbTable() ???\n" );
63  return 1;
64  }
65 
66  return 0;
67 }
68 
virtual void SetTable(char *data, int nrows, int *idList=0)
calloc&#39;d version of data for StRoot
Definition: StDbTable.cc:550
static StDbManager * Instance()
strdup(..) is not ANSI
Definition: StDbManager.cc:155