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

1.1     ! paf         1: /** @file
        !             2:        Parser: sql driver manager decls.
        !             3: 
        !             4:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
        !             5: 
        !             6:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
        !             7: 
        !             8:        $Id: pa_array.h,v 1.34 2001/04/03 05:23:40 paf Exp $
        !             9: 
        !            10: 
        !            11:        global sql driver manager, must be thread-safe
        !            12: */
        !            13: 
        !            14: #ifndef PA_SQL_DRIVER_MANAGER_H
        !            15: #define PA_SQL_DRIVER_MANAGER_H
        !            16: 
        !            17: #include "pa_pool.h"
        !            18: #include "pa_sql_driver.h"
        !            19: #include "pa_hash.h"
        !            20: #include "pa_stack.h"
        !            21: #include "pa_threads.h"
        !            22: #include "pa_table.h"
        !            23: #include "pa_string.h"
        !            24: 
        !            25: class SQL_Connection;
        !            26: 
        !            27: /// sql driver manager
        !            28: class SQL_Driver_manager : public Pooled {
        !            29:        friend SQL_Connection;
        !            30: public:
        !            31: 
        !            32:        SQL_Driver_manager(Pool& pool) : Pooled(pool),
        !            33:                driver_cache(pool),
        !            34:                connection_cache(pool) {
        !            35:        }
        !            36: 
        !            37:        /** 
        !            38:                connect to specified url, 
        !            39:                using driver dynamic library found in table, if not loaded yet
        !            40:                checks driver version
        !            41:        */
        !            42:        SQL_Connection& get_connection(const String& url, Table *protocol2library);
        !            43: 
        !            44: private: // driver cache
        !            45: 
        !            46:        SQL_Driver *get_driver_from_cache(const String& protocol);
        !            47:        void put_driver_to_cache(const String& protocol, SQL_Driver& driver);
        !            48: 
        !            49: private: // connection cache
        !            50: 
        !            51:        SQL_Connection *get_connection_from_cache(const String& url);
        !            52:        void put_connection_to_cache(const String& url, SQL_Connection& connection);
        !            53: 
        !            54: private: // for SQL_Connection
        !            55: 
        !            56:        /// caches connection
        !            57:        void close_connection(const String& url, SQL_Connection& connection);
        !            58: 
        !            59: private:
        !            60: 
        !            61:        Hash driver_cache;
        !            62:        Hash connection_cache;
        !            63: };
        !            64: 
        !            65: /// global
        !            66: extern SQL_Driver_manager *SQL_driver_manager;
        !            67: 
        !            68: 
        !            69: /// sql connection
        !            70: class SQL_Connection : public Pooled {
        !            71: 
        !            72: public:
        !            73: 
        !            74:        SQL_Connection(Pool& pool, 
        !            75:                SQL_Driver& adriver, void *ainfo, const String& aurl) : Pooled(pool),
        !            76:                fdriver(adriver),
        !            77:                finfo(ainfo),
        !            78:                furl(aurl) {
        !            79:        }
        !            80: 
        !            81:        void close() {
        !            82:                SQL_driver_manager->close_connection(furl, *this);
        !            83:        }
        !            84: 
        !            85:        void disconnect() {
        !            86:                fdriver.disconnect(finfo);
        !            87:        }
        !            88: 
        !            89: private:
        !            90: 
        !            91:        SQL_Driver& fdriver;
        !            92:        void *finfo;
        !            93:        const String& furl;
        !            94: };
        !            95: 
        !            96: #endif

E-mail: