QxOrm 1.1.9
C++ Object Relational Mapping library
QxThread.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** http://www.qxorm.com/
00004 ** http://sourceforge.net/projects/qxorm/
00005 ** Original file by Lionel Marty
00006 **
00007 ** This file is part of the QxOrm library
00008 **
00009 ** This software is provided 'as-is', without any express or implied
00010 ** warranty. In no event will the authors be held liable for any
00011 ** damages arising from the use of this software.
00012 **
00013 ** GNU Lesser General Public License Usage
00014 ** This file must be used under the terms of the GNU Lesser
00015 ** General Public License version 2.1 as published by the Free Software
00016 ** Foundation and appearing in the file 'license.lgpl.txt' included in the
00017 ** packaging of this file.  Please review the following information to
00018 ** ensure the GNU Lesser General Public License version 2.1 requirements
00019 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00020 **
00021 ** If you have questions regarding the use of this file, please contact :
00022 ** contact@qxorm.com
00023 **
00024 ****************************************************************************/
00025 
00026 #include <QxCommon/QxConfig.h> // Need to include this file for the 'moc' process
00027 
00028 #if _QX_ENABLE_QT_NETWORK_DEPENDENCY
00029 #ifndef _QX_SERVICE_THREAD_H_
00030 #define _QX_SERVICE_THREAD_H_
00031 
00032 #ifdef _MSC_VER
00033 #pragma once
00034 #endif
00035 
00043 #include <QtNetwork/qtcpsocket.h>
00044 
00045 #include <QxService/QxTransaction.h>
00046 
00047 namespace qx {
00048 namespace service {
00049 
00050 class QxThreadPool;
00051 
00058 class QX_DLL_EXPORT QxThread : public QThread
00059 { Q_OBJECT
00060 
00061 protected:
00062 
00063    int m_iSocketDescriptor;               
00064    QxThreadPool * m_pThreadPool;          
00065    QxTransaction_ptr m_pTransaction;      
00066    bool m_bIsRunning;                     
00067    QMutex m_mutex;                        
00068 
00069 public:
00070 
00071    QxThread(QxThreadPool * pool) : QThread(), m_iSocketDescriptor(0), m_pThreadPool(pool), m_bIsRunning(false) { qAssert(m_pThreadPool); }
00072    virtual ~QxThread() { clearData(); }
00073 
00074    bool isAvailable();
00075    void stop();
00076    void execute(int socketDescriptor);
00077 
00078 protected:
00079 
00080    virtual void run();
00081 
00082    void clearData();
00083    void doProcess(QTcpSocket & socket);
00084    qx_bool readSocket(QTcpSocket & socket);
00085    qx_bool writeSocket(QTcpSocket & socket);
00086 
00087 Q_SIGNALS:
00088 
00089    void error(const QString & err, qx::service::QxTransaction_ptr transaction);
00090    void transactionStarted(qx::service::QxTransaction_ptr transaction);
00091    void transactionFinished(qx::service::QxTransaction_ptr transaction);
00092 
00093 };
00094 
00095 } // namespace service
00096 } // namespace qx
00097 
00098 #endif // _QX_SERVICE_THREAD_H_
00099 #endif // _QX_ENABLE_QT_NETWORK_DEPENDENCY
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines