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

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.38    ! moko        5:        Copyright (c) 2001-2015 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.38    ! moko       12: #define IDENT_PA_SQL_DRIVER_MANAGER_H "$Id: pa_sql_driver_manager.h,v 1.37 2013/07/05 21:09:57 moko Exp $"
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:        driver_cache_type driver_cache;
                     44:        connection_cache_type connection_cache;
                     45: 
1.1       paf        46: public:
                     47: 
1.27      paf        48:        SQL_Driver_manager();
                     49:        override ~SQL_Driver_manager();
1.1       paf        50: 
                     51:        /** 
                     52:                connect to specified url, 
                     53:                using driver dynamic library found in table, if not loaded yet
                     54:                checks driver version
                     55:        */
1.31      paf        56:        SQL_Connection* get_connection(const String& aurl, 
                     57:                Table *protocol2driver_and_client,
1.34      misha      58:                const char* arequest_charset,
                     59:                const char* adocument_root);
1.1       paf        60: 
                     61: private: // driver cache
                     62: 
1.27      paf        63:        SQL_Driver *get_driver_from_cache(driver_cache_type::key_type protocol);
                     64:        void put_driver_to_cache(driver_cache_type::key_type protocol, driver_cache_type::value_type driver);
1.1       paf        65: 
                     66: private: // connection cache
                     67: 
1.27      paf        68:        SQL_Connection* get_connection_from_cache(connection_cache_type::key_type url);
                     69:        void put_connection_to_cache(connection_cache_type::key_type url, 
                     70:                SQL_Connection* connection);
1.7       parser     71: private:
                     72:        time_t prev_expiration_pass_time;
1.1       paf        73: 
                     74: private: // for SQL_Connection
                     75: 
                     76:        /// caches connection
1.27      paf        77:        void close_connection(connection_cache_type::key_type url, 
                     78:                SQL_Connection* connection);
1.15      paf        79: 
1.17      paf        80: public: // Cache_manager
1.15      paf        81: 
1.27      paf        82:        override Value* get_status();
                     83:        override void maybe_expire_cache();
1.15      paf        84: 
1.1       paf        85: };
                     86: 
                     87: /// global
1.30      paf        88: extern SQL_Driver_manager* SQL_driver_manager;
1.1       paf        89: 
                     90: #endif

E-mail: