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