src/sql/SqlFactory.cxx

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Prabakaran Thirumalai   *
00003  *   praba_tuty@yahoo.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 #include <SqlFactory.h>
00017 #include <SqlStatement.h>
00018 #include <SqlConnection.h>
00019 #include <SqlLogConnection.h>
00020 #include <SqlLogStatement.h>
00021 #include <SqlOdbcConnection.h>
00022 #include <SqlOdbcStatement.h>
00023 #include <SqlGwStatement.h>
00024 AbsSqlConnection* SqlFactory::createConnection(SqlApiImplType implFlag)
00025 {
00026     AbsSqlConnection *conn = NULL ;
00027     switch(implFlag)
00028     {
00029         case CSql:
00030             conn = new SqlConnection();
00031             break;
00032         case CSqlLog:
00033             {
00034             //generates sql logs
00035             AbsSqlConnection *sqlCon = new SqlConnection();
00036             conn = new SqlLogConnection();
00037             conn->setInnerConnection(sqlCon);
00038             break;
00039             }
00040         case CSqlAdapter:
00041             {
00042             conn = new SqlOdbcConnection();
00043             conn->setInnerConnection(NULL);
00044             break;
00045             }
00046         case CSqlGateway:
00047             {
00048             AbsSqlConnection *sqlCon = new SqlConnection();
00049             AbsSqlConnection *sqllogconn = new SqlLogConnection();
00050             sqllogconn->setInnerConnection(sqlCon);
00051             AbsSqlConnection *adapterCon = new SqlOdbcConnection();
00052             SqlGwConnection *gwconn = new SqlGwConnection();
00053             gwconn->setInnerConnection(sqllogconn);
00054             gwconn->setAdapter(adapterCon);
00055             conn = gwconn;
00056             break;
00057             }
00058         default:
00059             printf("Todo");
00060             break;
00061     }
00062     return conn;
00063 }
00064 AbsSqlStatement* SqlFactory::createStatement(SqlApiImplType implFlag)
00065 {
00066     AbsSqlStatement *stmt = NULL;
00067     switch(implFlag)
00068     {
00069         case CSql:
00070             stmt = new SqlStatement();
00071             break;
00072         case CSqlLog:
00073             {
00074             //generates sql logs
00075             AbsSqlStatement *sqlStmt = new SqlStatement();
00076             stmt = new SqlLogStatement();
00077             stmt->setInnerStatement(sqlStmt);
00078             break;
00079             }
00080         case CSqlAdapter:
00081             {
00082             stmt = new SqlOdbcStatement();
00083             stmt->setInnerStatement(NULL);
00084             break;
00085             }
00086         case CSqlGateway:
00087             {
00088             AbsSqlStatement *sqlstmt = new SqlStatement();
00089             AbsSqlStatement *sqllogstmt = new SqlLogStatement();
00090             sqllogstmt->setInnerStatement(sqlstmt);
00091             AbsSqlStatement *adapterstmt = new SqlOdbcStatement();
00092             SqlGwStatement *gwstmt = new SqlGwStatement();
00093             gwstmt->setInnerStatement(sqllogstmt);
00094             gwstmt->setAdapter(adapterstmt);
00095             stmt = gwstmt;
00096             break;
00097             }
00098         default:
00099             printf("Todo");
00100             break;
00101     }
00102     return stmt;
00103 }

Generated on Mon Jun 9 22:37:15 2008 for csql by  doxygen 1.4.7