Annotation of parser3/src/include/pa_db_manager.h, revision 1.2
1.1 parser 1: /** @file
2: Parser: sql driver manager decl.
3: global sql driver manager, must be thread-safe
4:
5: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
6: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
7:
1.2 ! parser 8: $Id: pa_db_manager.h,v 1.1 2001/10/22 16:44:42 parser Exp $
1.1 parser 9: */
10:
11: #ifndef PA_DB_DRIVER_MANAGER_H
12: #define PA_DB_DRIVER_MANAGER_H
13:
14: #include "pa_config_includes.h"
15: #include "pa_pool.h"
16: #include "pa_hash.h"
17:
18: #ifdef HAVE_DB_H
19: # include <db.h>
20: #endif
21:
22: // defines
23:
24: // forwards
25:
26: class DB_Connection;
27:
28: /// sql driver manager
29: class DB_Manager : public Pooled {
30: friend DB_Connection;
31: public:
32:
33: DB_Manager(Pool& pool);
34: ~DB_Manager();
35:
36: /**
37: connect to specified file_spec,
38: using driver dynamic library found in table, if not loaded yet
39: checks driver version
40: */
41: DB_Connection& get_connection(const String& file_spec, const String& request_origin);
1.2 ! parser 42: void clear_dbfile(const String& file_spec);
1.1 parser 43:
44: private: // connection cache
45:
46: DB_Connection *get_connection_from_cache(const String& file_spec);
47: void put_connection_to_cache(const String& file_spec, DB_Connection& connection);
48: void maybe_expire_connection_cache();
49: private:
50: time_t prev_expiration_pass_time;
51:
52: private: // for DB_Connection
53:
54: /// caches connection
55: void close_connection(const String& file_spec, DB_Connection& connection);
56:
57: private:
58:
59: Hash connection_cache;
60: DB_ENV dbenv;
61:
62: private:
63:
1.2 ! parser 64: void check(const char *operation, const String *source, int error);
1.1 parser 65: };
66:
67: /// global
68: extern DB_Manager *DB_manager;
69:
70: #endif
E-mail: