1 /***************************************************************************
2 * Copyright (C) 2007 by Prabakaran Thirumalai *
3 * praba_tuty@yahoo.com *
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. *
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. *
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>
29 AbsSqlConnection
* SqlFactory::createConnection(SqlApiImplType implFlag
)
31 AbsSqlConnection
*conn
= NULL
;
32 Conf::config
.readAllValues(os::getenv("CSQL_CONFIG_FILE"));
33 bool isSqlLogNeeded
= Conf::config
.useDurability();
38 if (!Conf::config
.useDurability()) {
39 conn
= new SqlConnection();
41 AbsSqlConnection
*sqlCon
= new SqlConnection();
42 conn
= new SqlLogConnection();
43 conn
->setInnerConnection(sqlCon
);
49 AbsSqlConnection
*sqlCon
= new SqlConnection();
50 conn
= new SqlLogConnection();
51 conn
->setInnerConnection(sqlCon
);
57 conn
= new SqlOdbcConnection();
58 conn
->setInnerConnection(NULL
);
63 AbsSqlConnection
*sqlCon
= new SqlConnection();
64 SqlGwConnection
*gwconn
= new SqlGwConnection();
66 AbsSqlConnection
*sqllogconn
= new SqlLogConnection();
67 sqllogconn
->setInnerConnection(sqlCon
);
68 gwconn
->setInnerConnection(sqllogconn
);
69 } else gwconn
->setInnerConnection(sqlCon
);
70 AbsSqlConnection
*adapterCon
= new SqlOdbcConnection();
71 gwconn
->setAdapter(adapterCon
);
78 SqlNwConnection
*sqlNwCon
= new SqlNwConnection(CSqlNetwork
);
79 sqlNwCon
->setInnerConnection(NULL
);
83 case CSqlNetworkAdapter
:
85 SqlNwConnection
*sqlNwCon
= new SqlNwConnection(CSqlNetworkAdapter
);
86 sqlNwCon
->setInnerConnection(NULL
);
90 case CSqlNetworkGateway
:
92 SqlNwConnection
*sqlNwCon
= new SqlNwConnection(CSqlNetworkGateway
);
93 sqlNwCon
->setInnerConnection(NULL
);
98 conn
= new SqlConnection();
107 AbsSqlStatement
* SqlFactory::createStatement(SqlApiImplType implFlag
)
109 AbsSqlStatement
*stmt
= NULL
;
110 bool isSqlLogNeeded
= Conf::config
.useDurability();
114 if (!Conf::config
.useDurability()) {
115 stmt
= new SqlStatement();
117 AbsSqlStatement
*sqlStmt
= new SqlStatement();
118 stmt
= new SqlLogStatement();
119 stmt
->setInnerStatement(sqlStmt
);
125 AbsSqlStatement
*sqlStmt
= new SqlStatement();
126 stmt
= new SqlLogStatement();
127 stmt
->setInnerStatement(sqlStmt
);
133 stmt
= new SqlOdbcStatement();
134 stmt
->setInnerStatement(NULL
);
139 SqlGwStatement
*gwstmt
= new SqlGwStatement();
140 AbsSqlStatement
*sqlstmt
= new SqlStatement();
141 if (isSqlLogNeeded
) {
142 AbsSqlStatement
*sqllogstmt
= new SqlLogStatement();
143 sqllogstmt
->setInnerStatement(sqlstmt
);
144 gwstmt
->setInnerStatement(sqllogstmt
);
145 } else gwstmt
->setInnerStatement(sqlstmt
);
146 AbsSqlStatement
*adapterstmt
= new SqlOdbcStatement();
147 gwstmt
->setAdapter(adapterstmt
);
154 SqlNwStatement
*sqlNwStmt
= new SqlNwStatement();
155 sqlNwStmt
->setInnerStatement(NULL
);
159 case CSqlNetworkAdapter
:
161 SqlNwStatement
*sqlNwStmt
= new SqlNwStatement();
162 sqlNwStmt
->setInnerStatement(NULL
);
166 case CSqlNetworkGateway
:
168 SqlNwStatement
*sqlNwStmt
= new SqlNwStatement();
169 sqlNwStmt
->setInnerStatement(NULL
);
174 stmt
= new SqlStatement();