• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

spl/data/Connection.h

00001 /*
00002  *   This file is part of the Standard Portable Library (SPL).
00003  *
00004  *   SPL is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   SPL is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with SPL.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #ifndef _idbconn_h
00018 #define _idbconn_h
00019 
00020 #include <spl/types.h>
00021 #include <spl/Debug.h>
00022 
00023 #include <spl/data/Command.h>
00024 #include <spl/Memory.h>
00025 #include <spl/data/RecordSet.h>
00026 #include <spl/RefCountPtr.h>
00027 #include <spl/String.h>
00028 #include <spl/data/Transaction.h>
00029 
00040 class Connection;
00041 typedef RefCountPtr<Connection> ConnectionPtr;
00042 
00047 class Connection : public IMemoryValidate
00048 {
00049 private:
00050         // Copy constructor doesn't make sense for this class
00051         inline Connection(const Connection& con) {}
00052         inline void operator =(const Connection& con) {}
00053 
00054 protected:
00055         String m_host;
00056         String m_database;
00057         String m_uid;
00058         String m_pw;
00059 
00060 public:
00061         Connection(const String& serverOrIP, const String& database, const String& uid, const String& pw);
00062         virtual ~Connection();
00063 
00065         virtual void Open() = 0;
00066 
00068         virtual void Close() = 0;
00069 
00071         virtual void ChangeDatabase(const String& db) = 0;
00072 
00073         virtual TransactionPtr BeginTransaction() = 0;
00074 
00075         virtual CommandPtr CreateCommand() = 0;
00076         virtual CommandPtr CreateCommand(const String& cmdText) = 0;
00077 
00078         virtual int ExecuteNonQuery(const String& sql) = 0;
00079         virtual RecordSetPtr ExecuteQuery(const String& sql) = 0;
00080 
00082         virtual void RegisterThread() = 0;
00083 
00085         virtual void RegisterThreadExit() = 0;
00086 
00088         virtual void AllowOutOfOrderCommandParameters(bool allow) = 0;
00089 
00090         static ConnectionPtr GetConnection(const String& connectString);
00091 
00092 #if defined(DEBUG)
00093         virtual void CheckMem() const;
00094         virtual void ValidateMem() const;
00095 #endif
00096 };
00097 
00101 #endif