CppDB
cppdb/conn_manager.h
00001 
00002 //                                                                             
00003 //  Copyright (C) 2010-2011  Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>     
00004 //                                                                             
00005 //  Distributed under:
00006 //
00007 //                   the Boost Software License, Version 1.0.
00008 //              (See accompanying file LICENSE_1_0.txt or copy at 
00009 //                     http://www.boost.org/LICENSE_1_0.txt)
00010 //
00011 //  or (at your opinion) under:
00012 //
00013 //                               The MIT License
00014 //                 (See accompanying file MIT.txt or a copy at
00015 //              http://www.opensource.org/licenses/mit-license.php)
00016 //
00018 #ifndef CPPDB_CONN_MANAGER_H
00019 #define CPPDB_CONN_MANAGER_H
00020 
00021 #include <cppdb/defs.h>
00022 #include <cppdb/ref_ptr.h>
00023 #include <cppdb/mutex.h>
00024 #include <map>
00025 #include <string>
00026 #include <memory>
00027 
00028 namespace cppdb {
00029         class pool;
00030         class connection_info;
00031         namespace backend {
00032                 class connection;
00033         }
00034 
00042         class CPPDB_API connections_manager {
00043                 connections_manager();
00044                 // Borland erros on hidden destructors in classes without only static methods.
00045                 #ifndef __BORLANDC__
00046                 ~connections_manager();
00047                 #endif
00048                 connections_manager(connections_manager const &);
00049                 void operator = (connections_manager const &);
00050         public:
00054                 static connections_manager &instance();
00058                 ref_ptr<backend::connection> open(std::string const &cs);
00062                 ref_ptr<backend::connection> open(connection_info const &ci);
00066                 void gc();
00067         private:
00068                 struct data;
00069                 std::auto_ptr<data> d;
00070 
00071                 mutex lock_;
00072                 typedef std::map<std::string,ref_ptr<pool> > connections_type;
00073                 connections_type connections_;
00074         };
00075 } // cppdb
00076 
00077 
00078 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator