Annotation of parser3/src/include/pa_sql_driver_manager.h, revision 1.12

1.1       paf         1: /** @file
1.2       paf         2:        Parser: sql driver manager decl.
1.10      parser      3:        global sql driver manager, must be thread-safe
1.1       paf         4: 
                      5:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
                      6:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
                      7: 
1.12    ! parser      8:        $Id: pa_sql_driver_manager.h,v 1.11 2001/09/21 15:35:45 parser Exp $
1.1       paf         9: */
                     10: 
                     11: #ifndef PA_SQL_DRIVER_MANAGER_H
                     12: #define PA_SQL_DRIVER_MANAGER_H
                     13: 
1.4       parser     14: #include "pa_config_includes.h"
1.1       paf        15: #include "pa_pool.h"
                     16: #include "pa_sql_driver.h"
                     17: #include "pa_hash.h"
                     18: #include "pa_stack.h"
                     19: #include "pa_table.h"
                     20: #include "pa_string.h"
1.8       parser     21: 
                     22: 
                     23: // defines
                     24: 
                     25: #define MAIN_SQL_NAME "SQL"
                     26: #define MAIN_SQL_DRIVERS_NAME "drivers"
                     27: 
                     28: // forwards
1.1       paf        29: 
                     30: class SQL_Connection;
                     31: 
1.11      parser     32: /// sql driver manager
1.1       paf        33: class SQL_Driver_manager : public Pooled {
                     34:        friend SQL_Connection;
                     35: public:
                     36: 
                     37:        SQL_Driver_manager(Pool& pool) : Pooled(pool),
                     38:                driver_cache(pool),
1.7       parser     39:                connection_cache(pool),
                     40:                prev_expiration_pass_time(0) {
1.1       paf        41:        }
                     42: 
                     43:        /** 
                     44:                connect to specified url, 
                     45:                using driver dynamic library found in table, if not loaded yet
                     46:                checks driver version
                     47:        */
1.10      parser     48:        SQL_Connection& get_connection(const String& url, const String& request_origin,
                     49:                Table *protocol2driver_and_client);
1.1       paf        50: 
                     51: private: // driver cache
                     52: 
                     53:        SQL_Driver *get_driver_from_cache(const String& protocol);
                     54:        void put_driver_to_cache(const String& protocol, SQL_Driver& driver);
                     55: 
                     56: private: // connection cache
                     57: 
                     58:        SQL_Connection *get_connection_from_cache(const String& url);
                     59:        void put_connection_to_cache(const String& url, SQL_Connection& connection);
1.7       parser     60:        void maybe_expire_connection_cache();
                     61: private:
                     62:        time_t prev_expiration_pass_time;
1.1       paf        63: 
                     64: private: // for SQL_Connection
                     65: 
                     66:        /// caches connection
1.6       parser     67:        void close_connection(const String& url, SQL_Connection& connection);
1.1       paf        68: 
                     69: private:
                     70: 
                     71:        Hash driver_cache;
                     72:        Hash connection_cache;
                     73: };
                     74: 
                     75: /// global
                     76: extern SQL_Driver_manager *SQL_driver_manager;
                     77: 
                     78: #endif

E-mail: