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

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

E-mail: