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

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.44    ! moko        5:        Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com)
1.42      moko        6:        Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <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.44    ! moko       12: #define IDENT_PA_SQL_DRIVER_MANAGER_H "$Id: pa_sql_driver_manager.h,v 1.43 2024/11/04 03:53:25 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.40      moko       56:        SQL_Connection* get_connection(const String& aurl, Table *protocol2driver_and_client, const char* arequest_charset, const char* adocument_root);
1.1       paf        57: 
                     58: private: // driver cache
                     59: 
1.27      paf        60:        SQL_Driver *get_driver_from_cache(driver_cache_type::key_type protocol);
                     61:        void put_driver_to_cache(driver_cache_type::key_type protocol, driver_cache_type::value_type driver);
1.1       paf        62: 
                     63: private: // connection cache
                     64: 
1.27      paf        65:        SQL_Connection* get_connection_from_cache(connection_cache_type::key_type url);
1.40      moko       66:        void put_connection_to_cache(connection_cache_type::key_type url, SQL_Connection* connection);
1.7       parser     67: private:
                     68:        time_t prev_expiration_pass_time;
1.1       paf        69: 
                     70: private: // for SQL_Connection
                     71: 
                     72:        /// caches connection
1.40      moko       73:        void close_connection(connection_cache_type::key_type url, SQL_Connection* connection);
1.15      paf        74: 
1.17      paf        75: public: // Cache_manager
1.15      paf        76: 
1.27      paf        77:        override Value* get_status();
                     78:        override void maybe_expire_cache();
1.15      paf        79: 
1.1       paf        80: };
                     81: 
                     82: /// global
1.30      paf        83: extern SQL_Driver_manager* SQL_driver_manager;
1.1       paf        84: 
                     85: #endif

E-mail: