include/Session.h

00001 /***************************************************************************
00002  *   Copyright (C) 2007 by www.databasecache.com                           *
00003  *   Contact: praba_tuty@databasecache.com                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015   ***************************************************************************/
00016 #ifndef SESSION_H
00017 #define SESSION_H
00018 #include<DatabaseManager.h>
00019 #include<UserManager.h>
00020 #include<ErrorType.h>
00021 class Session;
00026 enum IsolationLevel
00027 {
00028     READ_UNCOMMITTED = 1,
00029     READ_COMMITTED = 2,
00030     READ_REPEATABLE = 3,
00031     WRITE_OSYNC = 4 //this will work only from sqlapi
00032                     //for dbapi WRITE_OSYNC = READ_REPEATABLE
00033 };
00034 
00057 class Connection
00058 {
00059     Session *session;
00060     public:
00061     Connection() { session = NULL; }
00062     ~Connection(); 
00063 
00069     DbRetVal open(const char*username, const char*password);
00070 
00071 
00075     DbRetVal close();
00076 
00080     DatabaseManager* getDatabaseManager();
00081 
00085     UserManager* getUserManager();
00086 
00094     DbRetVal startTransaction(IsolationLevel level = READ_COMMITTED);
00095 
00103     DbRetVal commit();
00104 
00112     DbRetVal rollback();
00113 };
00114 
00115 
00116 class Session
00117 {
00118     public:
00119     virtual DbRetVal open(const char*username, const char*password)=0;
00120     virtual DbRetVal close()=0;
00121 
00122     virtual DatabaseManager* getDatabaseManager()=0;
00123     virtual UserManager* getUserManager()=0;
00124 
00125     virtual DbRetVal startTransaction(IsolationLevel level)=0;
00126     virtual DbRetVal commit()=0;
00127     virtual DbRetVal rollback()=0;
00128     //TODO:: virtual int setAutoCommit(bool flag)=0;
00129     //TODO::support for save points
00130     virtual ~Session() { }
00131 
00132 };
00133 
00134 
00135 
00136 #endif

CSQL Project Page