Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

odbc++/drivermanager.h

00001 /* 
00002    This file is part of libodbc++.
00003    
00004    Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
00005    
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010    
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015    
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.  If not, write to
00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
00020 */
00021 
00022 #ifndef __ODBCXX_DRIVERMANAGER_H
00023 #define __ODBCXX_DRIVERMANAGER_H
00024 
00025 #include <odbc++/setup.h>
00026 
00027 #include <odbc++/types.h>
00028 
00030 namespace odbc {
00031 
00032   class Connection;
00033   
00036   class ODBCXX_EXPORT Driver {
00037   private:
00038     ODBCXX_STRING description_;
00039     std::vector<ODBCXX_STRING> attributes_;
00040 
00041     Driver(const Driver&); //forbid
00042     Driver& operator=(const Driver&); //forbid
00043 
00044   public:
00046     Driver(const ODBCXX_STRING& description,
00047            const std::vector<ODBCXX_STRING>& attributes)
00048       :description_(description), attributes_(attributes) {}
00049 
00051     virtual ~Driver() {}
00052     
00054     const ODBCXX_STRING& getDescription() const {
00055       return description_;
00056     }
00057 
00059     const std::vector<ODBCXX_STRING>& getAttributes() const {
00060       return attributes_;
00061     }
00062   };
00063   
00065   typedef CleanVector<Driver*> DriverList;
00066   
00067 
00069   class ODBCXX_EXPORT DataSource {
00070   private:
00071     ODBCXX_STRING name_;
00072     ODBCXX_STRING description_;
00073 
00074   public:
00076     DataSource(const ODBCXX_STRING& name, const ODBCXX_STRING& description)
00077       :name_(name), description_(description) {}
00078     
00080     virtual ~DataSource() {}
00081 
00083     const ODBCXX_STRING& getName() const {
00084       return name_;
00085     }
00086     
00088     const ODBCXX_STRING& getDescription() const {
00089       return description_;
00090     }
00091   };
00092   
00094   typedef CleanVector<DataSource*> DataSourceList;
00095 
00096 
00099   class ODBCXX_EXPORT DriverManager {
00100   private:
00101     static SQLHENV henv_;
00102     static ErrorHandler* eh_;
00103     static int loginTimeout_;
00104     
00105     static void _checkInit();
00106     static Connection* _createConnection();
00107 
00108     // forbid
00109     DriverManager();
00110 
00111   public:
00112     
00114     static Connection* getConnection(const ODBCXX_STRING& dsn,
00115                                      const ODBCXX_STRING& user,
00116                                      const ODBCXX_STRING& password);
00117     
00121     static Connection* getConnection(const ODBCXX_STRING& connectString);
00122     
00126     static int getLoginTimeout();
00127 
00132     static void setLoginTimeout(int seconds);
00133 
00136     static DataSourceList* getDataSources();
00137 
00140     static DriverList* getDrivers();
00141 
00145     static void shutdown();
00146   };
00147 
00148 
00149 
00150 };
00151 
00152 
00153 #endif // __ODBCXX_DRIVERMANAGER_H

Go back to the freeodbc++ homepage