Annotation of parser3/src/include/pa_sql_driver_manager.h, revision 1.8.4.1
1.1 paf 1: /** @file
1.2 paf 2: Parser: sql driver manager decl.
1.1 paf 3:
4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
5:
6: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
7:
1.8.4.1 ! parser 8: $Id: pa_sql_driver_manager.h,v 1.8 2001/09/05 09:02:52 parser Exp $
1.1 paf 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:
1.4 parser 17: #include "pa_config_includes.h"
1.1 paf 18: #include "pa_pool.h"
19: #include "pa_sql_driver.h"
20: #include "pa_hash.h"
21: #include "pa_stack.h"
22: #include "pa_table.h"
23: #include "pa_string.h"
1.8 parser 24:
25:
26: // defines
27:
28: #define MAIN_SQL_NAME "SQL"
29: #define MAIN_SQL_DRIVERS_NAME "drivers"
30:
31: // forwards
1.1 paf 32:
33: class SQL_Connection;
34:
35: /// sql driver manager
36: class SQL_Driver_manager : public Pooled {
37: friend SQL_Connection;
38: public:
39:
40: SQL_Driver_manager(Pool& pool) : Pooled(pool),
41: driver_cache(pool),
1.7 parser 42: connection_cache(pool),
43: prev_expiration_pass_time(0) {
1.1 paf 44: }
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.8.4.1 ! parser 51: SQL_Connection& get_connection(const String& url, const String& request_origin,
! 52: Table *protocol2driver_and_client);
1.1 paf 53:
54: private: // driver cache
55:
56: SQL_Driver *get_driver_from_cache(const String& protocol);
57: void put_driver_to_cache(const String& protocol, SQL_Driver& driver);
58:
59: private: // connection cache
60:
61: SQL_Connection *get_connection_from_cache(const String& url);
62: void put_connection_to_cache(const String& url, SQL_Connection& connection);
1.7 parser 63: void maybe_expire_connection_cache();
64: private:
65: time_t prev_expiration_pass_time;
1.1 paf 66:
67: private: // for SQL_Connection
68:
69: /// caches connection
1.6 parser 70: void close_connection(const String& url, SQL_Connection& connection);
1.1 paf 71:
72: private:
73:
74: Hash driver_cache;
75: Hash connection_cache;
76: };
77:
78: /// global
79: extern SQL_Driver_manager *SQL_driver_manager;
80:
81: #endif
E-mail: