/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Calibration/rdbModel/rdbModel-00-01-01/src/Rdb.cxx

Go to the documentation of this file.
00001 // $Header: /bes/bes/BossCvs/Calibration/rdbModel/src/Rdb.cxx,v 1.1.1.1 2005/10/17 06:10:53 maqm Exp $ 
00002 #include "rdbModel/Rdb.h"
00003 #include "rdbModel/Tables/Table.h"
00004 #include "rdbModel/RdbException.h"
00005 
00006 namespace rdbModel {
00007 
00008   Rdb::~Rdb() {
00009     while (m_tables.size() ) {
00010       Table* table = m_tables.back();
00011       m_tables.pop_back();
00012       delete table;
00013     }
00014   }
00015 
00016   Table* Rdb::getTable(const std::string& name) const {
00017     unsigned nTable = m_tables.size();
00018     for (unsigned iTable = 0; iTable < nTable; iTable++) {
00019       Table* table = m_tables[iTable];
00020       if (table->getName() == name) return table;
00021     }
00022     return 0;
00023   }
00024 
00025   Column* Rdb::getColumn(const std::string& tableName, 
00026                          const std::string& colName) const {
00027     Table* table = getTable(tableName);
00028     if (!table) return 0;
00029 
00030     return table->getColumnByName(colName);
00031 
00032   }
00033 
00034   Index* Rdb::getIndex(const std::string& tableName, 
00035                        const std::string& indexName) const {
00036     Table* table = getTable(tableName);
00037     if (!table) return 0;
00038 
00039     return table->getIndexByName(indexName);
00040 
00041   }
00042 
00043   void Rdb::setConnection(Connection* connection) {
00044     m_connection = connection;
00045 
00046     // propagate to all our tables as well
00047     for (unsigned i = 0; i < m_tables.size(); i++) {
00048       m_tables[i]->setConnection(connection);
00049     }
00050   }
00051 
00052   int Rdb::insertRow(const std::string& tName, Row& row, int* serial) const {
00053     Table* t = getTable(tName);
00054     if (!t) {
00055       std::string msg("Rdb::insertRow unknown table ");
00056       msg = msg + tName;
00057       throw RdbException(msg);
00058     }
00059     return (t->insertRow(row, serial));
00060   }
00061 
00062   int Rdb::updateRows(const std::string& tName, Row& row, Assertion* where) const {
00063     Table* t = getTable(tName);
00064     if (!t) {
00065       std::string msg("Rdb::insertRow unknown table ");
00066       msg = msg + tName;
00067       throw RdbException(msg);
00068     }
00069     return (t->updateRows(row, where));
00070   }
00071 
00072   int Rdb::insertLatest(Table* t, Row& row, int* serial) const {
00073     return (t->insertLatest(row, serial));
00074   }
00075 
00076   int Rdb::insertLatest(const std::string& tName, Row& row, int* serial) 
00077     const {
00078     Table* t = getTable(tName);
00079     if (!t) {
00080       std::string msg("Rdb::insertLatest unknown table ");
00081       msg = msg + tName;
00082       throw RdbException(msg);
00083     }
00084     return (t->insertLatest(row, serial));
00085   }
00086 
00087   int Rdb::supersedeRow(const std::string& tName, Row& row, int oldKey, 
00088                         int* newKey) const {
00089     Table* t = getTable(tName);
00090     if (!t) {
00091       std::string msg("Rdb::supersedeRow unknown table ");
00092       msg = msg + tName;
00093       throw RdbException(msg);
00094     }
00095     return (t->supersedeRow(row, oldKey, newKey));
00096   }
00097 
00098   unsigned int Rdb::accept(Visitor* v) {
00099     Visitor::VisitorState state = v->visitRdb(this);
00100     if (state != Visitor::VCONTINUE) return state;
00101 
00102     unsigned nTable = m_tables.size();
00103 
00104     for (unsigned i = 0; i < nTable; i++) {
00105       state = m_tables[i]->accept(v);
00106       if (state != Visitor::VCONTINUE) return state;
00107     }
00108     return state;
00109   }
00110 
00111 
00112 }
00113     

Generated on Tue Nov 29 22:57:56 2016 for BOSS_7.0.2 by  doxygen 1.4.7