Annotation of parser3/src/include/pa_db_manager.h, revision 1.1
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:
! 8: $Id: pa_DB_driver_manager.h,v 1.12 2001/09/26 10:32:25 parser Exp $
! 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);
! 42:
! 43: private: // connection cache
! 44:
! 45: DB_Connection *get_connection_from_cache(const String& file_spec);
! 46: void put_connection_to_cache(const String& file_spec, DB_Connection& connection);
! 47: void maybe_expire_connection_cache();
! 48: private:
! 49: time_t prev_expiration_pass_time;
! 50:
! 51: private: // for DB_Connection
! 52:
! 53: /// caches connection
! 54: void close_connection(const String& file_spec, DB_Connection& connection);
! 55:
! 56: private:
! 57:
! 58: Hash connection_cache;
! 59: DB_ENV dbenv;
! 60:
! 61: private:
! 62:
! 63: void check(const char *operation, int error);
! 64: };
! 65:
! 66: /// global
! 67: extern DB_Manager *DB_manager;
! 68:
! 69: #endif
E-mail: