changing close to closescan
[csql.git] / src / sql / SqlFactory.cxx
blob2ce18b65fbf36d526dce23f2375bd2bc1d2b6ae3
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 #include <SqlNwConnection.h>
25 #include <SqlNwStatement.h>
27 AbsSqlConnection* SqlFactory::createConnection(SqlApiImplType implFlag)
29 AbsSqlConnection *conn = NULL ;
30 switch(implFlag)
32 case CSql:
33 conn = new SqlConnection();
34 break;
35 case CSqlLog:
37 //generates sql logs
38 AbsSqlConnection *sqlCon = new SqlConnection();
39 conn = new SqlLogConnection();
40 conn->setInnerConnection(sqlCon);
41 break;
43 case CSqlAdapter:
45 conn = new SqlOdbcConnection();
46 conn->setInnerConnection(NULL);
47 break;
49 case CSqlGateway:
51 AbsSqlConnection *sqlCon = new SqlConnection();
52 AbsSqlConnection *sqllogconn = new SqlLogConnection();
53 sqllogconn->setInnerConnection(sqlCon);
54 AbsSqlConnection *adapterCon = new SqlOdbcConnection();
55 SqlGwConnection *gwconn = new SqlGwConnection();
56 gwconn->setInnerConnection(sqllogconn);
57 gwconn->setAdapter(adapterCon);
58 conn = gwconn;
59 break;
61 case CSqlNetwork:
63 SqlNwConnection *sqlNwCon = new SqlNwConnection(CSqlNetwork);
64 sqlNwCon->setInnerConnection(NULL);
65 conn = sqlNwCon;
66 break;
68 case CSqlNetworkAdapter:
70 SqlNwConnection *sqlNwCon = new SqlNwConnection(CSqlNetworkAdapter);
71 sqlNwCon->setInnerConnection(NULL);
72 conn = sqlNwCon;
73 break;
75 case CSqlNetworkGateway:
77 SqlNwConnection *sqlNwCon = new SqlNwConnection(CSqlNetworkGateway);
78 sqlNwCon->setInnerConnection(NULL);
79 conn = sqlNwCon;
80 break;
83 default:
84 printf("Todo");
85 break;
87 return conn;
89 AbsSqlStatement* SqlFactory::createStatement(SqlApiImplType implFlag)
91 AbsSqlStatement *stmt = NULL;
92 switch(implFlag)
94 case CSql:
95 stmt = new SqlStatement();
96 break;
97 case CSqlLog:
99 //generates sql logs
100 AbsSqlStatement *sqlStmt = new SqlStatement();
101 stmt = new SqlLogStatement();
102 stmt->setInnerStatement(sqlStmt);
103 break;
105 case CSqlAdapter:
107 stmt = new SqlOdbcStatement();
108 stmt->setInnerStatement(NULL);
109 break;
111 case CSqlGateway:
113 AbsSqlStatement *sqlstmt = new SqlStatement();
114 AbsSqlStatement *sqllogstmt = new SqlLogStatement();
115 sqllogstmt->setInnerStatement(sqlstmt);
116 AbsSqlStatement *adapterstmt = new SqlOdbcStatement();
117 SqlGwStatement *gwstmt = new SqlGwStatement();
118 gwstmt->setInnerStatement(sqllogstmt);
119 gwstmt->setAdapter(adapterstmt);
120 stmt = gwstmt;
121 break;
123 case CSqlNetwork:
125 SqlNwStatement *sqlNwStmt = new SqlNwStatement();
126 sqlNwStmt->setInnerStatement(NULL);
127 stmt = sqlNwStmt;
128 break;
130 case CSqlNetworkAdapter:
132 SqlNwStatement *sqlNwStmt = new SqlNwStatement();
133 sqlNwStmt->setInnerStatement(NULL);
134 stmt=sqlNwStmt;
135 break;
137 case CSqlNetworkGateway:
139 SqlNwStatement *sqlNwStmt = new SqlNwStatement();
140 sqlNwStmt->setInnerStatement(NULL);
141 stmt = sqlNwStmt;
142 break;
145 default:
146 printf("Todo");
147 break;
149 return stmt;