|
|
| version 1.2, 2001/10/23 12:41:05 | version 1.11, 2001/12/13 11:09:46 |
|---|---|
| Line 3 | Line 3 |
| global sql driver manager, must be thread-safe | global sql driver manager, must be thread-safe |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) | Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru) |
| $Id$ | $Id$ |
| */ | */ |
| #ifndef PA_DB_DRIVER_MANAGER_H | #ifndef PA_DB_MANAGER_H |
| #define PA_DB_DRIVER_MANAGER_H | #define PA_DB_MANAGER_H |
| #include "pa_config_includes.h" | #include "pa_config_includes.h" |
| #include "pa_pool.h" | |
| #include "pa_hash.h" | #include "pa_hash.h" |
| #include "pa_db_connection.h" | |
| #ifdef HAVE_DB_H | #include "pa_cache_managers.h" |
| # include <db.h> | |
| #endif | |
| // defines | // defines |
| // forwards | // forwards |
| class DB_Connection; | |
| /// sql driver manager | /// sql driver manager |
| class DB_Manager : public Pooled { | class DB_Manager : public Cache_manager { |
| friend DB_Connection; | friend class DB_Connection; |
| public: | public: |
| DB_Manager(Pool& pool); | DB_Manager(Pool& apool); |
| ~DB_Manager(); | virtual ~DB_Manager(); |
| /** | /** |
| connect to specified file_spec, | connect to specified db_home, |
| using driver dynamic library found in table, if not loaded yet | using driver dynamic library found in table, if not loaded yet |
| checks driver version | checks driver version |
| */ | */ |
| DB_Connection& get_connection(const String& file_spec, const String& request_origin); | DB_Connection_ptr get_connection_ptr(const String& db_home, const String *source); |
| void clear_dbfile(const String& file_spec); | |
| private: // connection cache | private: // connection cache, never expires |
| DB_Connection *get_connection_from_cache(const String& file_spec); | DB_Connection *get_connection_from_cache(const String& db_home); |
| void put_connection_to_cache(const String& file_spec, DB_Connection& connection); | void put_connection_to_cache(const String& db_home, DB_Connection& connection); |
| void maybe_expire_connection_cache(); | |
| private: | private: |
| time_t prev_expiration_pass_time; | time_t prev_expiration_pass_time; |
| private: // for DB_Connection | |
| /// caches connection | |
| void close_connection(const String& file_spec, DB_Connection& connection); | |
| private: | private: |
| Hash connection_cache; | Hash connection_cache; |
| DB_ENV dbenv; | |
| private: | public: // Cache_manager |
| virtual Value& get_status(Pool& pool, const String *source); | |
| virtual void maybe_expire_cache(); | |
| void check(const char *operation, const String *source, int error); | |
| }; | }; |
| /// global | /// global |