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

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.26      paf         5:        Copyright (c) 2001, 2003 ArtLebedev Group (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.26.2.1! paf        12: static const char* IDENT_SQL_DRIVER_MANAGER_H="$Date: 2003/01/21 15:51:11 $";
1.1       paf        13: 
                     14: #include "pa_pool.h"
                     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.8       parser     20: 
                     21: // defines
                     22: 
                     23: #define MAIN_SQL_NAME "SQL"
                     24: #define MAIN_SQL_DRIVERS_NAME "drivers"
                     25: 
                     26: // forwards
1.1       paf        27: 
                     28: class SQL_Connection;
1.26.2.1! paf        29: DECLARE_OBJECT_PTR (SQL_Connection)
1.1       paf        30: 
1.11      parser     31: /// sql driver manager
1.26.2.1! paf        32: class SQL_Driver_manager: public Cache_manager {
1.14      paf        33:        friend class SQL_Connection;
1.1       paf        34: public:
                     35: 
1.26.2.1! paf        36:        SQL_Driver_manager();
        !            37:        override ~SQL_Driver_manager();
1.1       paf        38: 
                     39:        /** 
                     40:                connect to specified url, 
                     41:                using driver dynamic library found in table, if not loaded yet
                     42:                checks driver version
                     43:        */
1.26.2.1! paf        44:        SQL_ConnectionPtr get_connection(const String& url, const String& request_origin,
1.10      parser     45:                Table *protocol2driver_and_client);
1.1       paf        46: 
                     47: private: // driver cache
                     48: 
                     49:        SQL_Driver *get_driver_from_cache(const String& protocol);
                     50:        void put_driver_to_cache(const String& protocol, SQL_Driver& driver);
                     51: 
                     52: private: // connection cache
                     53: 
                     54:        SQL_Connection *get_connection_from_cache(const String& url);
                     55:        void put_connection_to_cache(const String& url, SQL_Connection& connection);
1.7       parser     56: private:
                     57:        time_t prev_expiration_pass_time;
1.1       paf        58: 
                     59: private: // for SQL_Connection
                     60: 
                     61:        /// caches connection
1.6       parser     62:        void close_connection(const String& url, SQL_Connection& connection);
1.1       paf        63: 
                     64: private:
                     65: 
1.26.2.1! paf        66:        Hash<const String&, SQL_Driver *> driver_cache;
1.1       paf        67:        Hash connection_cache;
1.15      paf        68: 
1.17      paf        69: public: // Cache_manager
1.15      paf        70: 
                     71:        virtual Value& get_status(Pool& pool, const String *source);
1.17      paf        72:        virtual void maybe_expire_cache();
1.15      paf        73: 
1.1       paf        74: };
                     75: 
                     76: /// global
1.26.2.1! paf        77: extern SQL_Driver_manager SQL_driver_manager;
1.1       paf        78: 
                     79: #endif

E-mail: