Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

dbconnection.h

00001 /* liblookdb: dbconnection.h - Database connection
00002     Copyright (C) 1998-2001 LOOK Systems
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Lesser General Public
00006     License as published by the Free Software Foundation; either
00007     version 2.1 of the License, or (at your option) any later version.
00008 
00009     This library 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 GNU
00012     Lesser General Public License for more details.
00013 
00014     You should have received a copy of the GNU Lesser General Public
00015     License along with this library; if not, write to the Free Software
00016     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 */
00018 #ifndef LIBLOOKDB_DBCONNECTION_H
00019 #define LIBLOOKDB_DBCONNECTION_H
00020 
00021 // $Id: dbconnection.h,v 1.7 2001/07/19 17:51:49 clive Exp $
00022 
00023 #include "lookdblibrary.h"
00024 #include "lookdbinterface.h"
00025 #include "lkstring.h"
00026 #include "t_list.h"
00027 
00028 namespace look {
00029 
00030 class DbConnection;
00031 
00032 #ifdef WIN32
00033 template class LOOKDBLIBRARY_DLL LookTLList<DbConnection*>;
00034 #endif
00035 typedef LookTLList<DbConnection*> ConnectionList;
00036 
00038 
00043 class LOOKDBLIBRARY_DLL DbConnection
00044 {
00045 public:
00046 
00048         enum ConnectionStyle
00049         {
00050                 DEFAULT,                 
00051                 AUTO_COMMIT,             
00052                 PERSISTENT_READ_ONLY     
00061         };
00062 
00063         DbConnection( const LookString& theDatabaseName = "",
00064                 const LookString& theUser = "",
00065                 const LookString& thePassword = "");
00066 
00067         DbConnection( const DbConnection& theConnection );
00068 
00069         virtual ~DbConnection();
00070 
00071         bool Connect(void);
00072         void Disconnect(void);
00073 
00074         bool Commit(void) const;
00075         bool Rollback(void) const;
00076 
00077         void SetConnectionStyle( ConnectionStyle theConnectionStyle )
00078         {
00079                 itsConnectionStyle = theConnectionStyle;
00080         }
00081 
00082         ConnectionStyle GetConnectionStyle( void )
00083         {
00084                 return itsConnectionStyle;
00085         }
00086 
00088         LOOK_DBC GetSession( void )
00089         {
00090                 return itsSessionNumber;
00091         }
00092 
00093         static void TerminateConnections( void );
00094 
00095         static DbConnection* GetGlobalConnection( void );
00096         static void SetGlobalConnection( DbConnection* theConnection );
00097 
00098 protected:
00099         LookString itsDatabaseName;
00100         LookString itsUser;
00101         LookString itsPassword;
00102         LOOK_DBC itsSessionNumber;
00103         bool itIsConnected;
00104 
00105         ConnectionStyle itsConnectionStyle; 
00106 
00107         static DbConnection* itsGlobalConnection;
00108 
00109         static ConnectionList itsConnections;
00110 };
00111 
00112 
00113 } // end of "look" namespace
00114 #endif 

Generated at Thu Jan 17 12:53:06 2002 for liblookdb by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001