Annotation of parser3/src/include/pa_sql_driver_manager.h, revision 1.26.2.4
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.4! paf 12: static const char* IDENT_SQL_DRIVER_MANAGER_H="$Date: 2003/01/27 17:17:06 $";
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.26.2.2 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;
1.26.2.1 paf 30: DECLARE_OBJECT_PTR (SQL_Connection)
1.1 paf 31:
1.11 parser 32: /// sql driver manager
1.26.2.1 paf 33: class SQL_Driver_manager: public Cache_manager {
1.14 paf 34: friend class SQL_Connection;
1.26.2.4! paf 35:
! 36: Pool driver_cache_pool;
! 37: typedef Hash<ConstStringPtr, SQL_Driver *> driver_cache_type;
! 38: driver_cache_type driver_cache;
! 39: typedef Hash<ConstStringPtr, object_ptr<Stack<SQL_ConnectionPtr> > > connection_cache_type;
! 40: connection_cache_type connection_cache;
! 41:
1.1 paf 42: public:
43:
1.26.2.1 paf 44: SQL_Driver_manager();
45: override ~SQL_Driver_manager();
1.1 paf 46:
47: /**
48: connect to specified url,
49: using driver dynamic library found in table, if not loaded yet
50: checks driver version
51: */
1.26.2.4! paf 52: SQL_ConnectionPtr get_connection(Pool& pool, ConstStringPtr arequest_url, ConstStringPtr aorigin,
1.10 parser 53: Table *protocol2driver_and_client);
1.1 paf 54:
55: private: // driver cache
56:
1.26.2.4! paf 57: SQL_Driver *get_driver_from_cache(driver_cache_type::key_type protocol);
! 58: void put_driver_to_cache(driver_cache_type::key_type protocol, driver_cache_type::value_type driver);
1.1 paf 59:
60: private: // connection cache
61:
1.26.2.4! paf 62: SQL_ConnectionPtr get_connection_from_cache(connection_cache_type::key_type url);
! 63: void put_connection_to_cache(connection_cache_type::key_type url,
! 64: SQL_ConnectionPtr connection);
1.7 parser 65: private:
66: time_t prev_expiration_pass_time;
1.1 paf 67:
68: private: // for SQL_Connection
69:
70: /// caches connection
1.26.2.4! paf 71: void close_connection(connection_cache_type::key_type url,
! 72: SQL_ConnectionPtr connection);
1.15 paf 73:
1.17 paf 74: public: // Cache_manager
1.15 paf 75:
1.26.2.2 paf 76: override ValuePtr get_status(Pool& pool, ConstStringPtr source);
77: override void maybe_expire_cache();
1.15 paf 78:
1.1 paf 79: };
80:
81: /// global
1.26.2.1 paf 82: extern SQL_Driver_manager SQL_driver_manager;
1.1 paf 83:
84: #endif
E-mail: