BOSS 8.0.0
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
2// maqm Exp $
3#include "rdbModel/Rdb.h"
4#include "rdbModel/RdbException.h"
5#include "rdbModel/Tables/Table.h"
6
7namespace rdbModel {
8
10 while ( m_tables.size() )
11 {
12 Table* table = m_tables.back();
13 m_tables.pop_back();
14 delete table;
15 }
16 }
17
18 Table* Rdb::getTable( const std::string& name ) const {
19 unsigned nTable = m_tables.size();
20 for ( unsigned iTable = 0; iTable < nTable; iTable++ )
21 {
22 Table* table = m_tables[iTable];
23 if ( table->getName() == name ) return table;
24 }
25 return 0;
26 }
27
28 Column* Rdb::getColumn( const std::string& tableName, const std::string& colName ) const {
29 Table* table = getTable( tableName );
30 if ( !table ) return 0;
31
32 return table->getColumnByName( colName );
33 }
34
35 Index* Rdb::getIndex( const std::string& tableName, const std::string& indexName ) const {
36 Table* table = getTable( tableName );
37 if ( !table ) return 0;
38
39 return table->getIndexByName( indexName );
40 }
41
42 void Rdb::setConnection( Connection* connection ) {
43 m_connection = connection;
44
45 // propagate to all our tables as well
46 for ( unsigned i = 0; i < m_tables.size(); i++ )
47 { m_tables[i]->setConnection( connection ); }
48 }
49
50 int Rdb::insertRow( const std::string& tName, Row& row, int* serial ) const {
51 Table* t = getTable( tName );
52 if ( !t )
53 {
54 std::string msg( "Rdb::insertRow unknown table " );
55 msg = msg + tName;
56 throw RdbException( msg );
57 }
58 return ( t->insertRow( row, serial ) );
59 }
60
61 int Rdb::updateRows( const std::string& tName, Row& row, Assertion* where ) const {
62 Table* t = getTable( tName );
63 if ( !t )
64 {
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 ) const {
77 Table* t = getTable( tName );
78 if ( !t )
79 {
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, int* newKey ) const {
88 Table* t = getTable( tName );
89 if ( !t )
90 {
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 {
106 state = m_tables[i]->accept( v );
107 if ( state != Visitor::VCONTINUE ) return state;
108 }
109 return state;
110 }
111
112} // namespace rdbModel
**********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:18
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:35
void setConnection(Connection *connection)
Definition Rdb.cxx:42
int updateRows(const std::string &tName, Row &row, Assertion *where) const
Definition Rdb.cxx:61
virtual ~Rdb()
Definition Rdb.cxx:9
Column * getColumn(const std::string &tableName, const std::string &colName) const
Definition Rdb.cxx:28
int insertRow(const std::string &tName, Row &row, int *serial=0) const
Definition Rdb.cxx:50
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:96
Column * getColumnByName(const std::string &name) const
Definition Table.cxx:67
int t()
Definition t.c:1