From: <ibr...@us...> - 2012-08-06 11:31:29
|
Revision: 4405 http://tora.svn.sourceforge.net/tora/?rev=4405&view=rev Author: ibre5041 Date: 2012-08-06 11:31:22 +0000 (Mon, 06 Aug 2012) Log Message: ----------- toeventquery cleanup Modified Paths: -------------- branches/tora3/src/core/toconnectionsubloan.h branches/tora3/src/core/toeventquery.cpp branches/tora3/src/core/toeventquery.h branches/tora3/src/core/toeventquerytask.cpp branches/tora3/src/core/toeventquerytask.h Modified: branches/tora3/src/core/toconnectionsubloan.h =================================================================== --- branches/tora3/src/core/toconnectionsubloan.h 2012-08-06 11:30:01 UTC (rev 4404) +++ branches/tora3/src/core/toconnectionsubloan.h 2012-08-06 11:31:22 UTC (rev 4405) @@ -5,9 +5,11 @@ class toConnection; class toConnectionSub; +class toEventQuery; class toConnectionSubLoan { + friend class toEventQuery; public: toConnectionSubLoan(toConnection &con); Modified: branches/tora3/src/core/toeventquery.cpp =================================================================== --- branches/tora3/src/core/toeventquery.cpp 2012-08-06 11:30:01 UTC (rev 4404) +++ branches/tora3/src/core/toeventquery.cpp 2012-08-06 11:31:22 UTC (rev 4405) @@ -59,20 +59,27 @@ : SQL(sql) , Param(param) , Statistics(stats) - , Task(0) + , Task(NULL) + , Connection(conn) + , Processed(0) + , Columns(0) + , TaskDone(false) { - - Connection = &conn; - Processed = 0; - Columns = 0; - TaskDone = false; } toEventQuery::toEventQuery(toConnectionSubLoan &conn , QString const& sql , toQueryParams const& param - , toResultStats *statistics + , toResultStats *stats ) + : SQL(sql) + , Param(param) + , Statistics(stats) + , Task(NULL) + , Connection(conn.Connection) + , Processed(0) + , Columns(0) + , TaskDone(false) { throw toConnection::exception("Not implemented yet: toEventQuery::toEventQuery(toConnectionSubLoan &conn..."); } @@ -112,7 +119,7 @@ void toEventQuery::start() { - Task = new toEventQueryTask(this, *Connection, SQL, Param //stat , Statistics + Task = new toEventQueryTask(*this, Connection, SQL, Param //stat , Statistics ); Task->ThreadAlive.lock(); Modified: branches/tora3/src/core/toeventquery.h =================================================================== --- branches/tora3/src/core/toeventquery.h 2012-08-06 11:30:01 UTC (rev 4404) +++ branches/tora3/src/core/toeventquery.h 2012-08-06 11:31:22 UTC (rev 4405) @@ -48,6 +48,7 @@ #include "core/toconnectionsub.h" #include "core/toconnectionsubloan.h" #include "core/toresultstats.h" +#include "core/toqvalue.h" #include <QObject> #include <QPointer> @@ -77,7 +78,7 @@ toQueryParams Param; // Number of rows processed. - int Processed; + unsigned long Processed; // Statistics to be used if any. QPointer<toResultStats> Statistics; @@ -86,7 +87,7 @@ toQColumnDescriptionList Description; // Number of columns in Description - int Columns; + unsigned Columns; // QThread instance that will do actual reading // Note: this pointer is NOT deleted by me, but by toRunnableThread::run/delete Runner @@ -102,7 +103,7 @@ volatile bool TaskDone; // connection for this query - toConnection *Connection; + toConnection &Connection; public: @@ -138,7 +139,6 @@ // ); toEventQuery(toConnectionSubLoan &conn -// , toQuery::queryMode mode , QString const& sql , toQueryParams const& param , toResultStats *statistics = NULL Modified: branches/tora3/src/core/toeventquerytask.cpp =================================================================== --- branches/tora3/src/core/toeventquerytask.cpp 2012-08-06 11:30:01 UTC (rev 4404) +++ branches/tora3/src/core/toeventquerytask.cpp 2012-08-06 11:31:22 UTC (rev 4405) @@ -48,6 +48,7 @@ #include "core/totool.h" #include "core/toconfiguration.h" #include "core/toquery.h" +#include "core/toqvalue.h" #include <QApplication> #include <QMutexLocker> @@ -88,7 +89,7 @@ } -toEventQueryTask::toEventQueryTask(toEventQuery *parent +toEventQueryTask::toEventQueryTask(toEventQuery &parent , toConnection &conn , QString const& sql , toQueryParams const& param @@ -98,12 +99,12 @@ , SQL(sql) , Params(param) , ParentQuery(parent) + , Query(0) + , Columns(0) + , Connection(conn) + , Closed(false) //stat , Statistics(stats) { - Query = 0; - Columns = 0; - Connection = &conn; - Closed = false; setObjectName("toEventQueryTask"); } @@ -112,7 +113,7 @@ { try { - Query = new toQuery(*Connection, SQL, Params); + Query = new toQuery(Connection, SQL, Params); //Query->execute(SQL, Params); connect(this, @@ -176,7 +177,7 @@ toEventQueryTask::~toEventQueryTask() { - ParentQuery->Task = NULL; + ParentQuery.Task = NULL; } @@ -237,7 +238,7 @@ for(int row = 0; row < maxRead; row++) { - for(int i = 0; i < Columns && !Query->eof(); i++) + for(unsigned i = 0; i < Columns && !Query->eof(); i++) values.append(Query->readValue()); } Modified: branches/tora3/src/core/toeventquerytask.h =================================================================== --- branches/tora3/src/core/toeventquerytask.h 2012-08-06 11:30:01 UTC (rev 4404) +++ branches/tora3/src/core/toeventquerytask.h 2012-08-06 11:31:22 UTC (rev 4405) @@ -60,7 +60,6 @@ class toResultStats; class toEventQuery; - /** * Threaded class used by toEventQuery. Internal to toEventQuery only. * @@ -70,6 +69,8 @@ */ class toEventQueryTask : public toRunnable { +private: + friend class toEventQuery; Q_OBJECT; // the real query object @@ -84,27 +85,24 @@ // Statistics to be used if any. //stat QPointer<toResultStats> Statistics; - toConnection *Connection; + toConnection &Connection; // object was closed volatile bool Closed; - toEventQuery *ParentQuery; + toEventQuery &ParentQuery; // can't synchronize on query or cancel wouldn't work, but need to // protect access during close() which may be called from the main // thread QMutex CloseLock; - -public: - // keeps thread from exiting until toEventQuery exits. this // prevents many race conditions and the caller can always assume // task is alive. QMutex ThreadAlive; - toEventQueryTask(toEventQuery *parent + toEventQueryTask(toEventQuery &parent , toConnection &conn , QString const& sql , toQueryParams const& param @@ -113,11 +111,8 @@ virtual ~toEventQueryTask(); protected: - - /** * Overrides toRunnable::run. Create toRunnableThread to start - * */ virtual void run(void); @@ -130,36 +125,28 @@ public slots: /** * Queues a read request. Emits readRequested() - * */ void read(bool all = false); /** * Closes this class. Good idea to call this. - * */ void close(void); - signals: // must be careful when defining signals. passing by reference // will share memory between threads. - /** * A read was requested - * */ void readRequested(bool all); - /** * Error message - * */ void error(const toConnection::exception &msg); - /** * Result headers * @@ -168,24 +155,18 @@ */ void headers(toQColumnDescriptionList &desc, int columns); - /** * Data read from query - * */ void data(ValuesList &values); - /** * Emitted when sql query is done - * */ void done(); - /** * Emitted if query.rowsProcessed() > 0. Number of affected rows. - * */ void rowsProcessed(int rows); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |