Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

dbstreamerfactory.hpp

Go to the documentation of this file.
00001 #if !defined(_DBStreamerFactory_HPP)
00002 #define _DBStreamerFactory_HPP
00003 //============================================================================= 
00004 //
00005 // XDFLengine library
00006 //
00007 //-----------------------------------------------------------------------------
00008 //  DBGETHANDLER.HPP
00009 //----------------------------------------------------------------------------- 
00015 //_____________________________________________________________________________
00016 //
00017 //  Copyright (C) 2003 Guillaume Baurand. All Rights Reserved.
00018 //
00019 //  This file is part of the XDFLengine project.
00020 //
00021 //  The XDFLengine is free software; you can redistribute it and/or modify
00022 //  it under the terms of the GNU General Public License as published by
00023 //  the Free Software Foundation; either version 2 of the License, or
00024 //  (at your option) any later version.
00025 //
00026 //  This program is distributed in the hope that it will be useful,
00027 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00028 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00029 //  GNU General Public License for more details.
00030 //
00031 //  You should have received a copy of the GNU General Public License
00032 //  along with this program; if not, write to the Free Software
00033 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
00034 //  USA.
00035 //
00036 //  For more information, 
00037 //      contact  : guillaume@baurand.net 
00038 //      or visit : http://xdflengine.sourceforge.net
00039 //
00040 //=============================================================================
00041 
00042 #   include "config/commonincs.hpp"
00043 #   include "processor/xmlstreamerfactory.hpp"
00044 #   include "utils/otl_utils.hpp" // OTL4
00045 
00046 BEGIN_XDFLENGINE_NS
00047 
00048 class DBConnectionPool;
00049 class XMLProcessor;
00050 
00051 
00052 //=============================================================================
00053 // GLOBALS
00054 //-----------------------------------------------------------------------------
00055 static unsigned long                g_ulPooledConnectionLifeTime;
00056 static bool                         g_boolConnectionPoolsReady=false; 
00057 static DBConnectionPool**           g_ppConnectionPools ;            
00058 
00059 #if defined(OTL_ODBC) 
00060     static unsigned int                 g_uiSQLSyntax = SQL_SYNTAX_MSSQL;
00061 #elif defined(OTL_ORA7) || defined(OTL_ORA8) || defined(OTL_ORA8I) || defined(OTL_ORA9I)
00062     static unsigned int                 g_uiSQLSyntax = SQL_SYNTAX_ORA;
00063 #elif defined(OTL_DB2_CLI)
00064     static unsigned int                 g_uiSQLSyntax = SQL_SYNTAX_DB2;
00065 #else
00066     static unsigned int                 g_uiSQLSyntax = SQL_SYNTAX_ORA;
00067 #endif
00068 
00069 //============================================================================= 
00070 //  CLASS DBStreamerFactory
00071 //----------------------------------------------------------------------------- 
00074 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00075 class XDFLENGINE_EXPORT DBStreamerFactory: public XMLStreamerFactory
00076 {
00077 
00078     protected: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00079 
00080 
00081     public: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00082 
00083     // CONTRUCTOR & DESTRUCTOR
00084 
00085         //_____________________________________________________________________
00086         //  setSQLSyntax
00087         //---------------------------------------------------------------------
00088         static void setSQLSyntax(const char* p_pszSQLSyntax=0);
00089 
00090         //_________________________________________________________________________
00091         //  GETCONNECTIONLIFETIME
00092         //-------------------------------------------------------------------------
00093         static unsigned int getSQLSyntax();
00094 
00095         //_____________________________________________________________________
00096         //  DBStreamerFactory
00097         //---------------------------------------------------------------------
00100         //_____________________________________________________________________
00101         DBStreamerFactory();
00102 
00103         //_____________________________________________________________________
00104         //  DBStreamerFactory
00105         //---------------------------------------------------------------------
00108         //_____________________________________________________________________
00109         virtual ~DBStreamerFactory();
00110 
00111     // CONNECTIONS      
00112 
00113         //_____________________________________________________________________
00114         // GETCONNECTION
00115         //---------------------------------------------------------------------
00116         otl_connect* getConnection(const char* p_pszConnectionString,unsigned int p_uiThreadId  );
00117 
00118 
00119         //_____________________________________________________________________
00120         // RELEASECONNECTION
00121         //---------------------------------------------------------------------
00122         void releaseConnection(const char* p_pszConnectionString,unsigned int p_uiThreadId  );
00123 
00124 
00125         //_____________________________________________________________________
00126         //  TICK
00127         //---------------------------------------------------------------------
00131         //_____________________________________________________________________
00132         void tick(unsigned long  p_ulClock);
00133 
00134 };
00135 //=============================================================================
00136 
00137 
00138 
00139 
00140 
00141 //============================================================================= 
00142 //  STRUCT DBPOOLEDCONNECTION
00143 //----------------------------------------------------------------------------- 
00145 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00146 typedef struct _DBPooledConnection
00147 {
00148         otl_connect*    m_pOTLConnection;   
00149         unsigned long   m_ulTimeCreated;
00150         unsigned int    m_uiUsage;
00151         char*           m_pszConnectionString;
00152 } DBPooledConnection;
00153 //=============================================================================
00154 
00155 
00156 
00157 
00158 
00159 
00160 //============================================================================= 
00161 //  CLASS DBCONNECTIONPOOL
00162 //----------------------------------------------------------------------------- 
00165 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00166 class XDFLENGINE_EXPORT DBConnectionPool
00167 {
00168 
00169     private: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00170         VAarray<DBPooledConnection* >   m_vaActiveConnections;
00171         unsigned long                       m_ulLastTick;
00172 
00173 
00174 
00175     public: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00176 
00177     // STATICS
00178         //_____________________________________________________________________
00179         //  SETCONNECTIONLIFETIME
00180         //--------------------------------------------------------------------- 
00181         static void setConnectionLifeTime(unsigned long  p_lngConnectionLifeTime);
00182 
00183     // CONTRUCTOR & DESTRUCTOR
00184 
00185         //_____________________________________________________________________
00186         //  DBStreamerFactory
00187         //---------------------------------------------------------------------
00190         //_____________________________________________________________________
00191         DBConnectionPool();
00192 
00193         //_____________________________________________________________________
00194         //  DBStreamerFactory
00195         //---------------------------------------------------------------------
00198         //_____________________________________________________________________
00199         ~DBConnectionPool();
00200 
00201 
00202     // CONNECTIONS      
00203 
00204         //_____________________________________________________________________
00205         // GETCONNECTION
00206         //---------------------------------------------------------------------
00207         otl_connect* getConnection(const char* p_pszConnectionString);
00208 
00209 
00210         //_____________________________________________________________________
00211         // RELEASECONNECTION
00212         //---------------------------------------------------------------------
00213         void releaseConnection(const char* p_pszConnectionString);
00214 
00215 
00216     // TICKER
00217 
00218         //_____________________________________________________________________
00219         //  TICK
00220         //---------------------------------------------------------------------
00221         void tick(unsigned long  p_ulClock);
00222 
00223 
00224     private:
00225         DBPooledConnection* poolConnection(const char* p_pszConnectionString);
00226         void unPoolConnection(DBPooledConnection*   p_pDBPooledConnection);
00227         void deletePooledConnection(DBPooledConnection* p_pDBPooledConnection);
00228 
00229 };
00230 //=============================================================================
00231 
00232 END_XDFLENGINE_NS
00233 
00234 #endif
00235   

Generated on Sat Oct 4 13:19:58 2003 for XDFLengine by doxygen1.3-rc2