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

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: 
1.36    ! moko        5:        Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com)
1.23      paf         6:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1       paf         7: */
                      8: 
                      9: #ifndef PA_SQL_DRIVER_MANAGER_H
                     10: #define PA_SQL_DRIVER_MANAGER_H
1.24      paf        11: 
1.36    ! moko       12: #define IDENT_PA_SQL_DRIVER_MANAGER_H "$Id: 2009-05-14 11:27:23 $"
1.27      paf        13: 
1.1       paf        14: 
                     15: #include "pa_sql_driver.h"
                     16: #include "pa_hash.h"
                     17: #include "pa_table.h"
                     18: #include "pa_string.h"
1.17      paf        19: #include "pa_cache_managers.h"
1.27      paf        20: #include "pa_stack.h"
1.8       parser     21: 
                     22: // defines
                     23: 
                     24: #define MAIN_SQL_NAME "SQL"
                     25: #define MAIN_SQL_DRIVERS_NAME "drivers"
                     26: 
                     27: // forwards
1.1       paf        28: 
                     29: class SQL_Connection;
                     30: 
1.11      parser     31: /// sql driver manager
1.27      paf        32: class SQL_Driver_manager: public Cache_manager {
                     33: public:
                     34: 
1.35      misha      35:        typedef HashString<SQL_Driver *> driver_cache_type;
1.27      paf        36:        typedef Stack<SQL_Connection*> connection_cache_element_base_type;
1.35      misha      37:        typedef HashString<connection_cache_element_base_type*> connection_cache_type;
1.27      paf        38: 
                     39: private:
                     40:        
1.14      paf        41:        friend class SQL_Connection;
1.27      paf        42: 
                     43:        bool is_dlinited;
                     44:        driver_cache_type driver_cache;
                     45:        connection_cache_type connection_cache;
                     46: 
1.1       paf        47: public:
                     48: 
1.27      paf        49:        SQL_Driver_manager();
                     50:        override ~SQL_Driver_manager();
1.1       paf        51: 
                     52:        /** 
                     53:                connect to specified url, 
                     54:                using driver dynamic library found in table, if not loaded yet
                     55:                checks driver version
                     56:        */
1.31      paf        57:        SQL_Connection* get_connection(const String& aurl, 
                     58:                Table *protocol2driver_and_client,
1.34      misha      59:                const char* arequest_charset,
                     60:                const char* adocument_root);
1.1       paf        61: 
                     62: private: // driver cache
                     63: 
1.27      paf        64:        SQL_Driver *get_driver_from_cache(driver_cache_type::key_type protocol);
                     65:        void put_driver_to_cache(driver_cache_type::key_type protocol, driver_cache_type::value_type driver);
1.1       paf        66: 
                     67: private: // connection cache
                     68: 
1.27      paf        69:        SQL_Connection* get_connection_from_cache(connection_cache_type::key_type url);
                     70:        void put_connection_to_cache(connection_cache_type::key_type url, 
                     71:                SQL_Connection* connection);
1.7       parser     72: private:
                     73:        time_t prev_expiration_pass_time;
1.1       paf        74: 
                     75: private: // for SQL_Connection
                     76: 
                     77:        /// caches connection
1.27      paf        78:        void close_connection(connection_cache_type::key_type url, 
                     79:                SQL_Connection* connection);
1.15      paf        80: 
1.17      paf        81: public: // Cache_manager
1.15      paf        82: 
1.27      paf        83:        override Value* get_status();
                     84:        override void maybe_expire_cache();
1.15      paf        85: 
1.1       paf        86: };
                     87: 
                     88: /// global
1.30      paf        89: extern SQL_Driver_manager* SQL_driver_manager;
1.1       paf        90: 
                     91: #endif

E-mail: