![]() |
QxOrm
1.2.7
C++ Object Relational Mapping library
|
00001 /**************************************************************************** 00002 ** 00003 ** http://www.qxorm.com/ 00004 ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com) 00005 ** 00006 ** This file is part of the QxOrm library 00007 ** 00008 ** This software is provided 'as-is', without any express or implied 00009 ** warranty. In no event will the authors be held liable for any 00010 ** damages arising from the use of this software 00011 ** 00012 ** Commercial Usage 00013 ** Licensees holding valid commercial QxOrm licenses may use this file in 00014 ** accordance with the commercial license agreement provided with the 00015 ** Software or, alternatively, in accordance with the terms contained in 00016 ** a written agreement between you and Lionel Marty 00017 ** 00018 ** GNU General Public License Usage 00019 ** Alternatively, this file may be used under the terms of the GNU 00020 ** General Public License version 3.0 as published by the Free Software 00021 ** Foundation and appearing in the file 'license.gpl3.txt' included in the 00022 ** packaging of this file. Please review the following information to 00023 ** ensure the GNU General Public License version 3.0 requirements will be 00024 ** met : http://www.gnu.org/copyleft/gpl.html 00025 ** 00026 ** If you are unsure which license is appropriate for your use, or 00027 ** if you have questions regarding the use of this file, please contact : 00028 ** contact@qxorm.com 00029 ** 00030 ****************************************************************************/ 00031 00032 #if _QX_ENABLE_QT_NETWORK_DEPENDENCY 00033 #ifndef _QX_SERVICE_TRANSACTION_H_ 00034 #define _QX_SERVICE_TRANSACTION_H_ 00035 00036 #ifdef _MSC_VER 00037 #pragma once 00038 #endif 00039 00047 #include <QtNetwork/qtcpsocket.h> 00048 00049 #include <QxCommon/QxBool.h> 00050 00051 #include <QxRegister/QxRegisterInternalHelper.h> 00052 00053 #include <QxService/IxService.h> 00054 #include <QxService/IxParameter.h> 00055 00056 namespace qx { 00057 namespace service { 00058 00065 class QX_DLL_EXPORT QxTransaction 00066 { 00067 00068 QX_REGISTER_FRIEND_CLASS(qx::service::QxTransaction) 00069 00070 protected: 00071 00072 QString m_sTransactionId; 00073 quint32 m_uiInputTransactionSize; 00074 quint32 m_uiOutputTransactionSize; 00075 QDateTime m_dtTransactionBegin; 00076 QDateTime m_dtTransactionRequestSent; 00077 QDateTime m_dtTransactionRequestReceived; 00078 QDateTime m_dtTransactionReplySent; 00079 QDateTime m_dtTransactionReplyReceived; 00080 QDateTime m_dtTransactionEnd; 00081 QString m_sIpSource; 00082 QString m_sIpTarget; 00083 long m_lPortSource; 00084 long m_lPortTarget; 00085 QString m_sServiceName; 00086 QString m_sServiceMethod; 00087 qx_bool m_bMessageReturn; 00088 IxParameter_ptr m_pInputParameter; 00089 IxParameter_ptr m_pOutputParameter; 00090 IxService_ptr m_pServiceInstance; 00091 00092 public: 00093 00094 QxTransaction() : m_uiInputTransactionSize(0), m_uiOutputTransactionSize(0), m_lPortSource(0), m_lPortTarget(0) { ; } 00095 virtual ~QxTransaction() { ; } 00096 00097 QString getTransactionId() const { return m_sTransactionId; } 00098 quint32 getInputTransactionSize() const { return m_uiInputTransactionSize; } 00099 quint32 getOutputTransactionSize() const { return m_uiOutputTransactionSize; } 00100 QDateTime getTransactionBegin() const { return m_dtTransactionBegin; } 00101 QDateTime getTransactionRequestSent() const { return m_dtTransactionRequestSent; } 00102 QDateTime getTransactionRequestReceived() const { return m_dtTransactionRequestReceived; } 00103 QDateTime getTransactionReplySent() const { return m_dtTransactionReplySent; } 00104 QDateTime getTransactionReplyReceived() const { return m_dtTransactionReplyReceived; } 00105 QDateTime getTransactionEnd() const { return m_dtTransactionEnd; } 00106 QString getIpSource() const { return m_sIpSource; } 00107 QString getIpTarget() const { return m_sIpTarget; } 00108 long getPortSource() const { return m_lPortSource; } 00109 long getPortTarget() const { return m_lPortTarget; } 00110 QString getServiceName() const { return m_sServiceName; } 00111 QString getServiceMethod() const { return m_sServiceMethod; } 00112 qx_bool getMessageReturn() const { return m_bMessageReturn; } 00113 IxParameter_ptr getInputParameter() const { return m_pInputParameter; } 00114 IxParameter_ptr getOutputParameter() const { return m_pOutputParameter; } 00115 00116 void setTransactionId(const QString & s) { m_sTransactionId = s; } 00117 void setInputTransactionSize(quint32 ui) { m_uiInputTransactionSize = ui; } 00118 void setOutputTransactionSize(quint32 ui) { m_uiOutputTransactionSize = ui; } 00119 void setTransactionBegin(const QDateTime & dt) { m_dtTransactionBegin = dt; } 00120 void setTransactionRequestSent(const QDateTime & dt) { m_dtTransactionRequestSent = dt; } 00121 void setTransactionRequestReceived(const QDateTime & dt) { m_dtTransactionRequestReceived = dt; } 00122 void setTransactionReplySent(const QDateTime & dt) { m_dtTransactionReplySent = dt; } 00123 void setTransactionReplyReceived(const QDateTime & dt) { m_dtTransactionReplyReceived = dt; } 00124 void setTransactionEnd(const QDateTime & dt) { m_dtTransactionEnd = dt; } 00125 void setIpSource(const QString & s) { m_sIpSource = s; } 00126 void setIpTarget(const QString & s) { m_sIpTarget = s; } 00127 void setPortSource(long l) { m_lPortSource = l; } 00128 void setPortTarget(long l) { m_lPortTarget = l; } 00129 void setServiceName(const QString & s) { m_sServiceName = s; } 00130 void setServiceMethod(const QString & s) { m_sServiceMethod = s; } 00131 void setMessageReturn(const qx_bool & b) { m_bMessageReturn = b; } 00132 void setInputParameter(IxParameter_ptr p) { m_pInputParameter = p; } 00133 void setOutputParameter(IxParameter_ptr p) { m_pOutputParameter = p; } 00134 00135 public: 00136 00137 void executeServer(); 00138 void executeClient(IxService * pService, const QString & sMethod); 00139 00140 protected: 00141 00142 qx_bool writeSocket(QTcpSocket & socket); 00143 qx_bool readSocket(QTcpSocket & socket); 00144 00145 }; 00146 00147 typedef boost::shared_ptr<QxTransaction> QxTransaction_ptr; 00148 QX_DLL_EXPORT void execute_client(IxService * pService, const QString & sMethod); 00149 00150 } // namespace service 00151 } // namespace qx 00152 00153 QX_REGISTER_INTERNAL_HELPER_HPP(QX_DLL_EXPORT, qx::service::QxTransaction, 0) 00154 00155 #endif // _QX_SERVICE_TRANSACTION_H_ 00156 #endif // _QX_ENABLE_QT_NETWORK_DEPENDENCY