![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
#include <DbConnectionFactory.h>
Inheritance diagram for SraData::DbConnectionFactory:Public Member Functions | |
| DbConnectionFactory (const std::string &dbName, const std::string &login, const std::string &password, const std::string &schema) | |
| sql::Connection * | getConnection () |
| void | recycleConnection (sql::Connection *conn) |
Protected Member Functions | |
| sql::Connection * | createInstance () |
Protected Attributes | |
| std::string | _dbName |
| sql::Driver * | _driver |
| std::string | _login |
| std::string | _password |
| std::string | _schema |
This class wraps the MySQL driver class, providing easier change for the future Also, for performance, this class may one day become an ObjectPool of connections for greater efficiency
Definition at line 18 of file DbConnectionFactory.h.
| SraData::DbConnectionFactory::DbConnectionFactory | ( | const std::string & | dbName, |
| const std::string & | login, | ||
| const std::string & | password, | ||
| const std::string & | schema | ||
| ) |
Sets the database information for this object, sets this instance as the Singleton, and initializes the MySQL driver
Definition at line 26 of file DbConnectionFactory.cpp.
References _driver, get_driver_instance(), ObjectPool< sql::Connection >::setDeleteAllInstances(), and Singleton< DbConnectionFactory >::SetSingleton().
:
_dbName(dbName),
_login(login),
_password(password),
_schema(schema)
{
//create an instance of the driver on creation of the factory
//this will be used to create connections in the future
_driver = get_driver_instance();
//set singleton up for this class
SetSingleton(this);
//when this factory dies, all of its children must die (so sad)
setDeleteAllInstances(true);
}
| sql::Connection * SraData::DbConnectionFactory::createInstance | ( | ) | [protected, virtual] |
Creates a MySQL connection instance using the settings of this factory instance
Implements ObjectPool< sql::Connection >.
Definition at line 15 of file DbConnectionFactory.cpp.
References _dbName, _driver, _login, _password, _schema, sql::Driver::connect(), and sql::Connection::setSchema().
| sql::Connection * SraData::DbConnectionFactory::getConnection | ( | ) |
Returns an instance from the connection pool
Definition at line 46 of file DbConnectionFactory.cpp.
References ObjectPool< sql::Connection >::getInstance().
Referenced by SraData::DbStream::DbStream().
{
return getInstance();
}
| void SraData::DbConnectionFactory::recycleConnection | ( | sql::Connection * | conn | ) |
returns an instance to the pool
Definition at line 54 of file DbConnectionFactory.cpp.
References ObjectPool< sql::Connection >::recycle().
Referenced by SraData::DbStream::~DbStream().
{
recycle(conn);
}
std::string SraData::DbConnectionFactory::_dbName [protected] |
Definition at line 23 of file DbConnectionFactory.h.
Referenced by createInstance().
sql::Driver* SraData::DbConnectionFactory::_driver [protected] |
Definition at line 21 of file DbConnectionFactory.h.
Referenced by createInstance(), and DbConnectionFactory().
std::string SraData::DbConnectionFactory::_login [protected] |
Definition at line 24 of file DbConnectionFactory.h.
Referenced by createInstance().
std::string SraData::DbConnectionFactory::_password [protected] |
Definition at line 25 of file DbConnectionFactory.h.
Referenced by createInstance().
std::string SraData::DbConnectionFactory::_schema [protected] |
Definition at line 26 of file DbConnectionFactory.h.
Referenced by createInstance().
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.