We use it when we want to:
- creates objects without exposing the instantiation logic to the client.
- refers to the newly created object through a common interface
class DBConnector : public QObject
{
Q_OBJECT
public:
DBConnector(QObject* parent=0);
~DBConnector();
virtual bool OpenConnection(QString aDatabaseName) = 0;
QSqlQuery GetData(QString aSqlQuery);
bool WriteData(QString aSqlQuery);
void commit();
void cleanUp();
protected:
QSqlDatabase* m_pDatabase;
QSqlQuery* m_pQuery;
signals:
void ConnectionErrorSignal(QString);
void QueryErrorSignal(QString);
};
class SqliteDBConnector : public DBConnector
{
public:
SqliteDBConnector();
bool OpenConnection(QString aDatabaseName);
};
bool DBManager::CreateDBConnectors()
{
DBConnector m_pMainDBConnector = new SqliteDBConnector();
return true;
}
No comments:
Post a Comment