Main Page   Class Hierarchy   File List  

openDB.cpp

00001 /*
00002   openDB.hpp includes openDB.h and any other
00003    implementation files used in the context of the executible.
00004    The other implementation file have defines
00005    that are used by the preprocessor to conditionally
00006    include cases in the switch statements of the factories
00007 
00008    Copyright 2002 - w3 Systems Development
00009    Author D.K.McCombs davidmc@w3sys.com
00010 */
00011 #include "openDB.hpp"
00012 
00013 // database object factory
00014 openDbFactory::openDbFactory( dbProvider dbProv, const char * strConnection )
00015 {
00016   pDB = NULL;
00017   switch( dbProv )
00018   {
00019 #ifdef OPENDBPG_H
00020   case PostGresQL:
00021     pDB = new postgresDB(strConnection);
00022     // cout << "PostgreSQL is providing data services" << endl;
00023     break;
00024 #endif
00025 #ifdef OPEN_ODBC_H
00026   case ODBC:
00027     pDB = new odbcDB(strConnection);
00028     break;
00029 #endif
00030 #ifdef OPEN_MYDB_H
00031   case MySQL:
00032     pDB = new mySqlDB(strConnection);
00033     break;
00034 #endif
00035   default:
00036     pDB = NULL;
00037     break;
00038   };
00039 }
00040 openDbFactory::~openDbFactory()
00041 {
00042   delete pDB;
00043 }
00044 openDB & openDbFactory::db()
00045 {
00046   return * pDB;
00047 }
00048 
00049 // recordset object factory
00050 openRsFactory::openRsFactory( openDB & rdb )
00051 {
00052   pRS = rdb.createRecordset();
00053 }
00054 
00055 openRsFactory::~openRsFactory()
00056 {
00057   delete pRS;
00058 }
00059 openRS & openRsFactory::rs()
00060 {
00061   return * pRS;
00062 }
00063 
00064 
00065 // command object factory
00066 openCmdFactory::openCmdFactory( openDB & rdb )
00067 {
00068   pCMD = rdb.createCommand();
00069 }
00070 openCmdFactory::~openCmdFactory()
00071 {
00072   delete pCMD;
00073 }
00074 openCMD & openCmdFactory::cmd()
00075 {
00076   return * pCMD;
00077 }
00078 
00079 /*
00080  This base class defines the interfaces to the database
00081 */
00082 openDB::openDB(  string strConnection ):m_bGood(false)
00083 {
00084   ;
00085 }
00086 openDB::~openDB()
00087 {
00088   ;// trivial implementation
00089 }
00090 
00091 /*
00092  This base class defines the interfaces to the command
00093 */
00094 openCMD::openCMD( openDB & idb ):rdb(idb),m_bTransactioning(false)
00095 {
00096   ;
00097 }
00098 openCMD::~openCMD()
00099 {
00100     ; // trivial implementation
00101 }
00102 
00103 /*
00104  This base class defines the interfaces to the recordset
00105 
00106  member vars:
00107   openDB    & rdb;
00108   fieldVector ordinals;
00109   fieldMap    associations;
00110   int         m_iRecords;
00111   int         m_iFields;
00112   bool        m_bOpen;
00113   bool        m_bTransactioning;
00114   string      m_strErrors;
00115 
00116 */
00117 openRS::openRS(openDB & idb )
00118 :rdb(idb),m_iRecords(0),m_iFields(0)
00119 ,m_bOpen(false),m_bTransactioning(false),m_strErrors("")
00120 {
00121   ;
00122 }
00123 openRS::~openRS()
00124 {
00125   ; // trivial implementation
00126 }
00127 
00128 // non-trivially implemented here
00129 basicField & openRS::getField( int idx )
00130 {
00131   return * ordinals[idx];
00132 }
00133 // non-trivially implemented here
00134 basicField & openRS::getField( const char * name )
00135 {
00136   return * associations[name];
00137 }
00138 
00139 

Generated on Tue Jan 20 09:06:56 2004 for OpenTools by doxygen1.2.18