Annotation of parser3/src/include/pa_sql_driver_manager.h, revision 1.10
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:
5: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
6:
7: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
8:
1.10 ! parser 9: $Id: pa_sql_driver_manager.h,v 1.9 2001/09/14 15:41:59 parser Exp $
1.1 paf 10: */
11:
12: #ifndef PA_SQL_DRIVER_MANAGER_H
13: #define PA_SQL_DRIVER_MANAGER_H
14:
1.4 parser 15: #include "pa_config_includes.h"
1.1 paf 16: #include "pa_pool.h"
17: #include "pa_sql_driver.h"
18: #include "pa_hash.h"
19: #include "pa_stack.h"
20: #include "pa_table.h"
21: #include "pa_string.h"
1.8 parser 22:
23:
24: // defines
25:
26: #define MAIN_SQL_NAME "SQL"
27: #define MAIN_SQL_DRIVERS_NAME "drivers"
28:
29: // forwards
1.1 paf 30:
31: class SQL_Connection;
32:
1.9 parser 33: /** sql driver manager
34: maintains
35: - driver cache which never expires
36: - connection cache unused connections got expired
37: */
1.1 paf 38: class SQL_Driver_manager : public Pooled {
39: friend SQL_Connection;
40: public:
41:
42: SQL_Driver_manager(Pool& pool) : Pooled(pool),
43: driver_cache(pool),
1.7 parser 44: connection_cache(pool),
45: prev_expiration_pass_time(0) {
1.1 paf 46: }
47:
48: /**
49: connect to specified url,
50: using driver dynamic library found in table, if not loaded yet
51: checks driver version
52: */
1.10 ! parser 53: SQL_Connection& get_connection(const String& url, const String& request_origin,
! 54: Table *protocol2driver_and_client);
1.1 paf 55:
56: private: // driver cache
57:
58: SQL_Driver *get_driver_from_cache(const String& protocol);
59: void put_driver_to_cache(const String& protocol, SQL_Driver& driver);
60:
61: private: // connection cache
62:
63: SQL_Connection *get_connection_from_cache(const String& url);
64: void put_connection_to_cache(const String& url, SQL_Connection& connection);
1.7 parser 65: void maybe_expire_connection_cache();
66: private:
67: time_t prev_expiration_pass_time;
1.1 paf 68:
69: private: // for SQL_Connection
70:
71: /// caches connection
1.6 parser 72: void close_connection(const String& url, SQL_Connection& connection);
1.1 paf 73:
74: private:
75:
76: Hash driver_cache;
77: Hash connection_cache;
78: };
79:
80: /// global
81: extern SQL_Driver_manager *SQL_driver_manager;
82:
83: #endif
E-mail: