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