BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
Rdb.cxx
Go to the documentation of this file.
1// $Header: /bes/bes/BossCvs/Calibration/rdbModel/src/Rdb.cxx,v 1.1.1.1 2005/10/17 06:10:53 maqm Exp $
2#include "rdbModel/Rdb.h"
3#include "rdbModel/Tables/Table.h"
4#include "rdbModel/RdbException.h"
5
6namespace rdbModel {
7
9 while (m_tables.size() ) {
10 Table* table = m_tables.back();
11 m_tables.pop_back();
12 delete table;
13 }
14 }
15
16 Table* Rdb::getTable(const std::string& name) const {
17 unsigned nTable = m_tables.size();
18 for (unsigned iTable = 0; iTable < nTable; iTable++) {
19 Table* table = m_tables[iTable];
20 if (table->getName() == name) return table;
21 }
22 return 0;
23 }
24
25 Column* Rdb::getColumn(const std::string& tableName,
26 const std::string& colName) const {
27 Table* table = getTable(tableName);
28 if (!table) return 0;
29
30 return table->getColumnByName(colName);
31
32 }
33
34 Index* Rdb::getIndex(const std::string& tableName,
35 const std::string& indexName) const {
36 Table* table = getTable(tableName);
37 if (!table) return 0;
38
39 return table->getIndexByName(indexName);
40
41 }
42
43 void Rdb::setConnection(Connection* connection) {
44 m_connection = connection;
45
46 // propagate to all our tables as well
47 for (unsigned i = 0; i < m_tables.size(); i++) {
48 m_tables[i]->setConnection(connection);
49 }
50 }
51
52 int Rdb::insertRow(const std::string& tName, Row& row, int* serial) const {
53 Table* t = getTable(tName);
54 if (!t) {
55 std::string msg("Rdb::insertRow unknown table ");
56 msg = msg + tName;
57 throw RdbException(msg);
58 }
59 return (t->insertRow(row, serial));
60 }
61
62 int Rdb::updateRows(const std::string& tName, Row& row, Assertion* where) const {
63 Table* t = getTable(tName);
64 if (!t) {
65 std::string msg("Rdb::insertRow unknown table ");
66 msg = msg + tName;
67 throw RdbException(msg);
68 }
69 return (t->updateRows(row, where));
70 }
71
72 int Rdb::insertLatest(Table* t, Row& row, int* serial) const {
73 return (t->insertLatest(row, serial));
74 }
75
76 int Rdb::insertLatest(const std::string& tName, Row& row, int* serial)
77 const {
78 Table* t = getTable(tName);
79 if (!t) {
80 std::string msg("Rdb::insertLatest unknown table ");
81 msg = msg + tName;
82 throw RdbException(msg);
83 }
84 return (t->insertLatest(row, serial));
85 }
86
87 int Rdb::supersedeRow(const std::string& tName, Row& row, int oldKey,
88 int* newKey) const {
89 Table* t = getTable(tName);
90 if (!t) {
91 std::string msg("Rdb::supersedeRow unknown table ");
92 msg = msg + tName;
93 throw RdbException(msg);
94 }
95 return (t->supersedeRow(row, oldKey, newKey));
96 }
97
98 unsigned int Rdb::accept(Visitor* v) {
99 Visitor::VisitorState state = v->visitRdb(this);
100 if (state != Visitor::VCONTINUE) return state;
101
102 unsigned nTable = m_tables.size();
103
104 for (unsigned i = 0; i < nTable; i++) {
105 state = m_tables[i]->accept(v);
106 if (state != Visitor::VCONTINUE) return state;
107 }
108 return state;
109 }
110
111
112}
113
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition: KarLud.h:35
int supersedeRow(const std::string &tName, Row &row, int oldKey, int *newKey=0) const
Definition: Rdb.cxx:87
Table * getTable(const std::string &name) const
Definition: Rdb.cxx:16
int insertLatest(Table *t, Row &row, int *serial=0) const
Definition: Rdb.cxx:72
Index * getIndex(const std::string &tableName, const std::string &indexName) const
Definition: Rdb.cxx:34
void setConnection(Connection *connection)
Definition: Rdb.cxx:43
int updateRows(const std::string &tName, Row &row, Assertion *where) const
Definition: Rdb.cxx:62
virtual ~Rdb()
Definition: Rdb.cxx:8
Column * getColumn(const std::string &tableName, const std::string &colName) const
Definition: Rdb.cxx:25
int insertRow(const std::string &tName, Row &row, int *serial=0) const
Definition: Rdb.cxx:52
unsigned int accept(Visitor *v)
This is the recursive accept for the visitor pattern.
Definition: Rdb.cxx:98
Index * getIndexByName(const std::string &name) const
Definition: Table.cxx:82
Column * getColumnByName(const std::string &name) const
Definition: Table.cxx:56
int t()
Definition: t.c:1