/*
This file is part of libodbc++.
Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __ODBCXX_DRIVERMANAGER_H
#define __ODBCXX_DRIVERMANAGER_H
#include <odbc++/setup.h>
#include <odbc++/types.h>
namespace odbc {
class Connection;
class ODBCXX_EXPORT Driver {
private:
ODBCXX_STRING description_;
std::vector<ODBCXX_STRING> attributes_;
Driver(const Driver&); //forbid
Driver& operator=(const Driver&); //forbid
public:
Driver(const ODBCXX_STRING& description,
const std::vector<ODBCXX_STRING>& attributes)
:description_(description), attributes_(attributes) {}
virtual ~Driver() {}
const ODBCXX_STRING& getDescription() const {
return description_;
}
const std::vector<ODBCXX_STRING>& getAttributes() const {
return attributes_;
}
};
typedef CleanVector<Driver*> DriverList;
class ODBCXX_EXPORT DataSource {
private:
ODBCXX_STRING name_;
ODBCXX_STRING description_;
public:
DataSource(const ODBCXX_STRING& name, const ODBCXX_STRING& description)
:name_(name), description_(description) {}
virtual ~DataSource() {}
const ODBCXX_STRING& getName() const {
return name_;
}
const ODBCXX_STRING& getDescription() const {
return description_;
}
};
typedef CleanVector<DataSource*> DataSourceList;
class ODBCXX_EXPORT DriverManager {
private:
static SQLHENV henv_;
static ErrorHandler* eh_;
static int loginTimeout_;
static void _checkInit();
static Connection* _createConnection();
public:
static Connection* getConnection(const ODBCXX_STRING& dsn,
const ODBCXX_STRING& user,
const ODBCXX_STRING& password);
static Connection* getConnection(const ODBCXX_STRING& connectString);
static int getLoginTimeout();
static void setLoginTimeout(int seconds);
static DataSourceList* getDataSources();
static DriverList* getDrivers();
static void shutdown();
};
};
#endif // __ODBCXX_DRIVERMANAGER_H