rdbModel::Rdb Class Reference

#include <Rdb.h>

List of all members.

Public Member Functions

virtual ~Rdb ()
 Rdb ()
unsigned getMajorVersion ()
unsigned getMinorVersion ()
const std::stringgetCVSid ()
const std::stringgetDbName ()
TablegetTable (const std::string &name) const
ColumngetColumn (const std::string &tableName, const std::string &colName) const
IndexgetIndex (const std::string &tableName, const std::string &indexName) const
unsigned int getNTable () const
void setConnection (Connection *connection)
int insertRow (const std::string &tName, Row &row, int *serial=0) const
int insertLatest (Table *t, Row &row, int *serial=0) const
int insertLatest (const std::string &tName, Row &row, int *serial=0) const
int supersedeRow (const std::string &tName, Row &row, int oldKey, int *newKey=0) const
int updateRows (const std::string &tName, Row &row, Assertion *where) const
unsigned int accept (Visitor *v)
 This is the recursive accept for the visitor pattern.

Private Member Functions

void setCVSid (std::string pcvs)
void addTable (Table *t)

Private Attributes

std::vector< Table * > m_tables
std::string m_dbName
 SQL database name (e.g., "calib").
unsigned m_majorVersion
 The Schema version from the input xml description.
unsigned m_minorVersion
std::string m_CVSid
 The CVSid from the input xml description.
Connectionm_connection

Friends

class rdbModel::XercesBuilder


Detailed Description

This is the main container of all the rdb description. The Manager is responsible for its creation and destruction. Provide both a query interface (provide various functions to look up components by name) and also accept visitors.

Adapted from detModel::Gdd class, written by R. Giannitrapani and D. Favretto

Author:
J. Bogart

Definition at line 41 of file Rdb.h.


Constructor & Destructor Documentation

rdbModel::Rdb::~Rdb (  )  [virtual]

This is the destructor; it should be called only by the manager destructor. It starts the destruction of all the objects created by the builder

Definition at line 8 of file Rdb.cxx.

References m_tables.

00008             {
00009     while (m_tables.size() ) {
00010       Table* table = m_tables.back();
00011       m_tables.pop_back();
00012       delete table;
00013     }
00014   }

rdbModel::Rdb::Rdb (  )  [inline]

Definition at line 48 of file Rdb.h.

00048 : m_connection(0) { }


Member Function Documentation

unsigned int rdbModel::Rdb::accept ( Visitor v  ) 

This is the recursive accept for the visitor pattern.

Definition at line 98 of file Rdb.cxx.

References genRecEmupikp::i, m_tables, v, and rdbModel::Visitor::VCONTINUE.

Referenced by rdbModel::MysqlConnection::matchSchema(), and rdbModel::Manager::startVisitor().

00098                                      {
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   }

void rdbModel::Rdb::addTable ( Table t  )  [inline, private]

Definition at line 117 of file Rdb.h.

Referenced by rdbModel::XercesBuilder::buildRdb().

00117 {m_tables.push_back(t);};

Column * rdbModel::Rdb::getColumn ( const std::string tableName,
const std::string colName 
) const

Definition at line 25 of file Rdb.cxx.

References rdbModel::Table::getColumnByName(), and getTable().

Referenced by main().

00026                                                          {
00027     Table* table = getTable(tableName);
00028     if (!table) return 0;
00029 
00030     return table->getColumnByName(colName);
00031 
00032   }

const std::string& rdbModel::Rdb::getCVSid (  )  [inline]

Definition at line 54 of file Rdb.h.

References m_CVSid.

00054 {return m_CVSid;};

const std::string& rdbModel::Rdb::getDbName (  )  [inline]

Definition at line 56 of file Rdb.h.

References m_dbName.

Referenced by rdbModel::MysqlConnection::visitRdb().

00056 {return m_dbName;};

Index * rdbModel::Rdb::getIndex ( const std::string tableName,
const std::string indexName 
) const

Definition at line 34 of file Rdb.cxx.

References rdbModel::Table::getIndexByName(), and getTable().

00035                                                          {
00036     Table* table = getTable(tableName);
00037     if (!table) return 0;
00038 
00039     return table->getIndexByName(indexName);
00040 
00041   }

unsigned rdbModel::Rdb::getMajorVersion (  )  [inline]

Definition at line 51 of file Rdb.h.

References m_majorVersion.

00051 {return m_majorVersion;};

unsigned rdbModel::Rdb::getMinorVersion (  )  [inline]

Definition at line 52 of file Rdb.h.

References m_minorVersion.

00052 {return m_minorVersion;};

unsigned int rdbModel::Rdb::getNTable (  )  const [inline]

Definition at line 68 of file Rdb.h.

References m_tables.

Referenced by rdbModel::MysqlConnection::visitRdb().

00068 {return m_tables.size();}

Table * rdbModel::Rdb::getTable ( const std::string name  )  const

Definition at line 16 of file Rdb.cxx.

References m_tables.

Referenced by calibUtil::Metadata::checkNulls(), calibUtil::Metadata::checkValues(), getColumn(), getIndex(), insertLatest(), insertRow(), main(), supersedeRow(), and updateRows().

00016                                                   {
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   }

int rdbModel::Rdb::insertLatest ( const std::string tName,
Row row,
int *  serial = 0 
) const

Definition at line 76 of file Rdb.cxx.

References getTable(), deljobs::string, and t().

00077           {
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   }

int rdbModel::Rdb::insertLatest ( Table t,
Row row,
int *  serial = 0 
) const

The two forms of smart insert, in addition to filling in the service fields, as insertRow does, do various forms of consistency checking and may even update pre-existing rows.

Definition at line 72 of file Rdb.cxx.

References t().

Referenced by doSmartInsert().

00072                                                              {
00073     return (t->insertLatest(row, serial));
00074   }

int rdbModel::Rdb::insertRow ( const std::string tName,
Row row,
int *  serial = 0 
) const

insertRow has only one value-added feature as compared to an SQL insert: it will take care of fields intended to be filled by the service (e.g., insert and update timestamps)

Definition at line 52 of file Rdb.cxx.

References getTable(), deljobs::string, and t().

Referenced by doInsert().

00052                                                                         {
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   }

void rdbModel::Rdb::setConnection ( Connection connection  ) 

Definition at line 43 of file Rdb.cxx.

References genRecEmupikp::i, m_connection, and m_tables.

Referenced by rdbModel::MysqlConnection::visitRdb().

00043                                                 {
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   }

void rdbModel::Rdb::setCVSid ( std::string  pcvs  )  [inline, private]

Definition at line 115 of file Rdb.h.

References m_CVSid.

00115 {m_CVSid = pcvs;};

int rdbModel::Rdb::supersedeRow ( const std::string tName,
Row row,
int  oldKey,
int *  newKey = 0 
) const

Definition at line 87 of file Rdb.cxx.

References getTable(), deljobs::string, and t().

Referenced by doSupersede().

00088                                            {
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   }

int rdbModel::Rdb::updateRows ( const std::string tName,
Row row,
Assertion where 
) const

Fills in service fields, then invokes Connection::update

Definition at line 62 of file Rdb.cxx.

References getTable(), deljobs::string, t(), and boss::where().

Referenced by doUpdate().

00062                                                                               {
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   }


Friends And Related Function Documentation

friend class rdbModel::XercesBuilder [friend]

Definition at line 112 of file Rdb.h.


Member Data Documentation

Connection* rdbModel::Rdb::m_connection [private]

Definition at line 134 of file Rdb.h.

Referenced by setConnection().

std::string rdbModel::Rdb::m_CVSid [private]

The CVSid from the input xml description.

Definition at line 133 of file Rdb.h.

Referenced by rdbModel::XercesBuilder::buildRdb(), getCVSid(), and setCVSid().

std::string rdbModel::Rdb::m_dbName [private]

SQL database name (e.g., "calib").

Definition at line 127 of file Rdb.h.

Referenced by rdbModel::XercesBuilder::buildRdb(), and getDbName().

unsigned rdbModel::Rdb::m_majorVersion [private]

The Schema version from the input xml description.

Definition at line 129 of file Rdb.h.

Referenced by rdbModel::XercesBuilder::buildRdb(), and getMajorVersion().

unsigned rdbModel::Rdb::m_minorVersion [private]

Definition at line 130 of file Rdb.h.

Referenced by rdbModel::XercesBuilder::buildRdb(), and getMinorVersion().

std::vector<Table* > rdbModel::Rdb::m_tables [private]

Definition at line 117 of file Rdb.h.

Referenced by accept(), getNTable(), getTable(), setConnection(), and ~Rdb().


Generated on Tue Nov 29 23:36:36 2016 for BOSS_7.0.2 by  doxygen 1.4.7