unique support for tree index
[csql.git] / src / sql / SqlFactory.cxx
blob145e1ea0f6ad8e53bd8241b81c2d1a62c05113ab
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 #include <SqlFactory.h>
17 #include <SqlStatement.h>
18 #include <SqlConnection.h>
19 #include <SqlLogConnection.h>
20 #include <SqlLogStatement.h>
21 #include <SqlOdbcConnection.h>
22 #include <SqlOdbcStatement.h>
23 #include <SqlGwStatement.h>
24 AbsSqlConnection* SqlFactory::createConnection(SqlApiImplType implFlag)
26 AbsSqlConnection *conn = NULL ;
27 switch(implFlag)
29 case CSql:
30 conn = new SqlConnection();
31 break;
32 case CSqlLog:
34 //generates sql logs
35 AbsSqlConnection *sqlCon = new SqlConnection();
36 conn = new SqlLogConnection();
37 conn->setInnerConnection(sqlCon);
38 break;
40 case CSqlAdapter:
42 conn = new SqlOdbcConnection();
43 conn->setInnerConnection(NULL);
44 break;
46 case CSqlGateway:
48 AbsSqlConnection *sqlCon = new SqlConnection();
49 AbsSqlConnection *sqllogconn = new SqlLogConnection();
50 sqllogconn->setInnerConnection(sqlCon);
51 AbsSqlConnection *adapterCon = new SqlOdbcConnection();
52 SqlGwConnection *gwconn = new SqlGwConnection();
53 gwconn->setInnerConnection(sqllogconn);
54 gwconn->setAdapter(adapterCon);
55 conn = gwconn;
56 break;
58 default:
59 printf("Todo");
60 break;
62 return conn;
64 AbsSqlStatement* SqlFactory::createStatement(SqlApiImplType implFlag)
66 AbsSqlStatement *stmt = NULL;
67 switch(implFlag)
69 case CSql:
70 stmt = new SqlStatement();
71 break;
72 case CSqlLog:
74 //generates sql logs
75 AbsSqlStatement *sqlStmt = new SqlStatement();
76 stmt = new SqlLogStatement();
77 stmt->setInnerStatement(sqlStmt);
78 break;
80 case CSqlAdapter:
82 stmt = new SqlOdbcStatement();
83 stmt->setInnerStatement(NULL);
84 break;
86 case CSqlGateway:
88 AbsSqlStatement *sqlstmt = new SqlStatement();
89 AbsSqlStatement *sqllogstmt = new SqlLogStatement();
90 sqllogstmt->setInnerStatement(sqlstmt);
91 AbsSqlStatement *adapterstmt = new SqlOdbcStatement();
92 SqlGwStatement *gwstmt = new SqlGwStatement();
93 gwstmt->setInnerStatement(sqllogstmt);
94 gwstmt->setAdapter(adapterstmt);
95 stmt = gwstmt;
96 break;
98 default:
99 printf("Todo");
100 break;
102 return stmt;