Initial revision
[csql.git] / include / Session.h
blobdf7c35d9604e4b7e12150d447bcd554b53af91be
1 /***************************************************************************
2 * Copyright (C) 2007 by Prabakaran Thirumalai *
3 * praba_tuty@yahoo.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 ***************************************************************************/
16 #ifndef SESSION_H
17 #define SESSION_H
18 #include<DatabaseManager.h>
19 #include<UserManager.h>
20 #include<ErrorType.h>
21 class Session;
23 //Currently it suppors only READ REPEATABLE transaction isolation level.
24 //TODO::to implement READ COMMITTED and DIRTY READ isolation level
25 //NOT to DO: SERIALIZABLE isolation level
26 class Connection
28 Session *session;
29 public:
30 Connection() { session = NULL; }
31 ~Connection() { delete session; }
32 DbRetVal open(const char*username, const char*password);
33 DbRetVal close();
34 DatabaseManager* getDatabaseManager();
35 UserManager* getUserManager();
36 DbRetVal startTransaction();
37 DbRetVal commit();
38 DbRetVal rollback();
40 class Session
42 public:
43 virtual DbRetVal open(const char*username, const char*password)=0;
44 virtual DbRetVal close()=0;
46 virtual DatabaseManager* getDatabaseManager()=0;
47 virtual UserManager* getUserManager()=0;
49 virtual DbRetVal startTransaction()=0;
50 virtual DbRetVal commit()=0;
51 virtual DbRetVal rollback()=0;
52 //TODO:: virtual int setAutoCommit(bool flag)=0;
53 //TODO::support for save points
54 virtual ~Session() { }
58 #endif