A command class for used in QueryQueue. More...
#include <querythreadcommand.h>
Public Member Functions | |
QueryThreadCommand () | |
QueryThreadCommand (const QObject *sender) | |
QueryThreadCommand (const QObject *sender, const QString &query) | |
QueryThreadCommand (const QObject *sender, const QQueue< QString > &queryQueue) | |
QueryThreadCommand (const QueryThreadCommand &original) | |
bool | operator== (const QueryThreadCommand &other) const |
void | enqueueQuery (const QString &query) |
QString | dequeueQuery () |
bool | isValid () const |
bool | isEmpty () const |
QObject * | transmitter () |
void | setResult (const QSharedPointer< QSqlQuery > &result) |
QSqlQuery * | result () const |
const QObject * | sender () const |
A command class for used in QueryQueue.
m_sender should be guarded (i.e. QPointer<QObject>)
m_transmitter should be const
copy-constructor and operator= should be implemented.
QueryThreadCommand::QueryThreadCommand | ( | ) | [inline] |
: m_sender(0), m_transmitter(new QObject()) {}
QueryThreadCommand::QueryThreadCommand | ( | const QObject * | sender | ) | [inline] |
: m_sender(sender), m_transmitter(new QObject()) {}
: m_sender(sender), m_transmitter(new QObject()) { enqueueQuery(query); }
QueryThreadCommand::QueryThreadCommand | ( | const QObject * | sender, | |
const QQueue< QString > & | queryQueue | |||
) | [inline] |
: m_sender(sender), m_transmitter(new QObject()) { m_queryQueue.append(queryQueue); }
QueryThreadCommand::QueryThreadCommand | ( | const QueryThreadCommand & | original | ) | [inline] |
: m_sender(original.m_sender), m_result(original.m_result), m_transmitter(original.m_transmitter) { m_queryQueue = original.m_queryQueue; }
QString QueryThreadCommand::dequeueQuery | ( | ) |
Referenced by QueryWorker::slotExecute().
{ return m_queryQueue.dequeue(); }
void QueryThreadCommand::enqueueQuery | ( | const QString & | query | ) |
Referenced by QueryThreadCommand().
{ m_queryQueue.enqueue(query); }
bool QueryThreadCommand::isEmpty | ( | ) | const |
Referenced by QueryWorker::slotExecute().
{ return !isValid(); }
bool QueryThreadCommand::isValid | ( | ) | const |
Referenced by Database::execThreaded(), isEmpty(), and QueryWorker::slotExecute().
{
return (!m_queryQueue.isEmpty() && m_sender);
}
bool QueryThreadCommand::operator== | ( | const QueryThreadCommand & | other | ) | const |
{ //nodig voor de queue! (i.e. er mag maar een zelfde command in queue zijn!) return (this->m_sender == other.m_sender); }
QSqlQuery * QueryThreadCommand::result | ( | ) | const |
Referenced by Database::slot_queryThreadResult().
{ return m_result.data(); }
const QObject * QueryThreadCommand::sender | ( | ) | const |
Referenced by Database::execPending(), Database::execThreaded(), and Database::slot_queryThreadResult().
{
return m_sender;
};
void QueryThreadCommand::setResult | ( | const QSharedPointer< QSqlQuery > & | result | ) |
Referenced by QueryWorker::slotExecute().
{ m_result = result; }