BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
ReadRuntripFromDb Class Reference

#include <ReadRuntripFromDb.h>

Public Member Functions

 ReadRuntripFromDb ()
 
 ~ReadRuntripFromDb ()
 
string gettimest (int i)
 
string gettimend (int i)
 
int getstSize ()
 
int getndSize ()
 
void ReadDb (int run)
 
bool isRunTripped ()
 

Detailed Description

Definition at line 12 of file ReadRuntripFromDb.h.

Constructor & Destructor Documentation

◆ ReadRuntripFromDb()

ReadRuntripFromDb::ReadRuntripFromDb ( )

Definition at line 6 of file ReadRuntripFromDb.cxx.

6 :
7 m_isTrip(false){
8 }

◆ ~ReadRuntripFromDb()

ReadRuntripFromDb::~ReadRuntripFromDb ( )

Definition at line 10 of file ReadRuntripFromDb.cxx.

11{
12 timest.clear();
13 timend.clear();
14}

Member Function Documentation

◆ getndSize()

int ReadRuntripFromDb::getndSize ( )

Definition at line 112 of file ReadRuntripFromDb.cxx.

113{
114 return timend.size();
115}

Referenced by MdcTripSvc::getTripFlag().

◆ getstSize()

int ReadRuntripFromDb::getstSize ( )

Definition at line 107 of file ReadRuntripFromDb.cxx.

108{
109 return timest.size();
110}

Referenced by MdcTripSvc::getTripFlag().

◆ gettimend()

string ReadRuntripFromDb::gettimend ( int  i)

Definition at line 102 of file ReadRuntripFromDb.cxx.

103{
104 return timend[i];
105}

Referenced by MdcTripSvc::getTripFlag().

◆ gettimest()

string ReadRuntripFromDb::gettimest ( int  i)

Definition at line 98 of file ReadRuntripFromDb.cxx.

99{
100 return timest[i];
101}

Referenced by MdcTripSvc::getTripFlag().

◆ isRunTripped()

bool ReadRuntripFromDb::isRunTripped ( )

Definition at line 93 of file ReadRuntripFromDb.cxx.

94{
95 return m_isTrip;
96}

Referenced by MdcTripSvc::getTripFlag().

◆ ReadDb()

void ReadRuntripFromDb::ReadDb ( int  run)

Definition at line 41 of file ReadRuntripFromDb.cxx.

42{
43 MYSQL* mysql=OpenDb();
44 char stmt[1024];
45
46 snprintf(stmt, 1024,
47 "select trip_start, trip_stop "
48 "from RunParams where run_number = %d", run);
49 //printf("--------- %s -------\n",stmt);
50 if (mysql_real_query(mysql, stmt, strlen(stmt)))
51 {
52 fprintf(stderr, "query error\n");
53 m_isTrip = false;
54 CloseDb(mysql);
55 return;
56 }
57 MYSQL_RES* result_set = mysql_store_result(mysql);
58 MYSQL_ROW row = mysql_fetch_row(result_set);
59 if (row[0]==NULL || row[1]==NULL)
60 {
61 fprintf(stderr, "can't find trip information for tripped run: %d\n", run);
62 mysql_free_result(result_set);
63 CloseDb(mysql);
64 m_isTrip = false;
65 return;
66 }
67
68 timest.clear();
69 timend.clear();
70 char *token;
71 char *doken;
72 token = strtok(row[0],",");
73 string tripst(token);
74 timest.push_back(tripst);
75 while((token =strtok(NULL,","))!= NULL){
76 string tripst(token);
77 timest.push_back(tripst);
78 }
79 doken = strtok(row[1],",");
80 string tripnd(doken);
81 timend.push_back(tripnd);
82 while((doken = strtok(NULL,","))!= NULL){
83 string tripnd(doken);
84 timend.push_back(tripnd);
85 }
86
87 // Free the memory to prevent memory leak!
88 mysql_free_result(result_set);
89 CloseDb(mysql);
90 m_isTrip = true;
91}
struct st_mysql_res MYSQL_RES
struct st_mysql MYSQL

Referenced by MdcTripSvc::getTripFlag().


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