![]() |
QxOrm
1.4.1
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 #ifdef _QX_ENABLE_QT_NETWORK 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 <QtCore/qdatastream.h> 00048 00049 #include <QtNetwork/qtcpsocket.h> 00050 00051 #include <QxCommon/QxBool.h> 00052 00053 #include <QxRegister/QxRegisterInternalHelper.h> 00054 00055 #include <QxService/IxService.h> 00056 #include <QxService/IxParameter.h> 00057 00058 namespace qx { 00059 namespace service { 00060 class QxTransaction; 00061 } // namespace service 00062 } // namespace qx 00063 00064 QX_DLL_EXPORT QDataStream & operator<< (QDataStream & stream, const qx::service::QxTransaction & t) BOOST_USED; 00065 QX_DLL_EXPORT QDataStream & operator>> (QDataStream & stream, qx::service::QxTransaction & t) BOOST_USED; 00066 00067 namespace qx { 00068 namespace service { 00069 00076 class QX_DLL_EXPORT QxTransaction 00077 { 00078 00079 QX_REGISTER_FRIEND_CLASS(qx::service::QxTransaction) 00080 00081 friend QDataStream & ::operator<< (QDataStream & stream, const qx::service::QxTransaction & t); 00082 friend QDataStream & ::operator>> (QDataStream & stream, qx::service::QxTransaction & t); 00083 00084 protected: 00085 00086 QString m_sTransactionId; 00087 quint32 m_uiInputTransactionSize; 00088 quint32 m_uiOutputTransactionSize; 00089 QDateTime m_dtTransactionBegin; 00090 QDateTime m_dtTransactionRequestSent; 00091 QDateTime m_dtTransactionRequestReceived; 00092 QDateTime m_dtTransactionReplySent; 00093 QDateTime m_dtTransactionReplyReceived; 00094 QDateTime m_dtTransactionEnd; 00095 QString m_sIpSource; 00096 QString m_sIpTarget; 00097 long m_lPortSource; 00098 long m_lPortTarget; 00099 QString m_sServiceName; 00100 QString m_sServiceMethod; 00101 qx_bool m_bMessageReturn; 00102 IxParameter_ptr m_pInputParameter; 00103 IxParameter_ptr m_pOutputParameter; 00104 IxService_ptr m_pServiceInstance; 00105 00106 public: 00107 00108 QxTransaction() : m_uiInputTransactionSize(0), m_uiOutputTransactionSize(0), m_lPortSource(0), m_lPortTarget(0) { ; } 00109 virtual ~QxTransaction() { ; } 00110 00111 QString getTransactionId() const { return m_sTransactionId; } 00112 quint32 getInputTransactionSize() const { return m_uiInputTransactionSize; } 00113 quint32 getOutputTransactionSize() const { return m_uiOutputTransactionSize; } 00114 QDateTime getTransactionBegin() const { return m_dtTransactionBegin; } 00115 QDateTime getTransactionRequestSent() const { return m_dtTransactionRequestSent; } 00116 QDateTime getTransactionRequestReceived() const { return m_dtTransactionRequestReceived; } 00117 QDateTime getTransactionReplySent() const { return m_dtTransactionReplySent; } 00118 QDateTime getTransactionReplyReceived() const { return m_dtTransactionReplyReceived; } 00119 QDateTime getTransactionEnd() const { return m_dtTransactionEnd; } 00120 QString getIpSource() const { return m_sIpSource; } 00121 QString getIpTarget() const { return m_sIpTarget; } 00122 long getPortSource() const { return m_lPortSource; } 00123 long getPortTarget() const { return m_lPortTarget; } 00124 QString getServiceName() const { return m_sServiceName; } 00125 QString getServiceMethod() const { return m_sServiceMethod; } 00126 qx_bool getMessageReturn() const { return m_bMessageReturn; } 00127 IxParameter_ptr getInputParameter() const { return m_pInputParameter; } 00128 IxParameter_ptr getOutputParameter() const { return m_pOutputParameter; } 00129 00130 void setTransactionId(const QString & s) { m_sTransactionId = s; } 00131 void setInputTransactionSize(quint32 ui) { m_uiInputTransactionSize = ui; } 00132 void setOutputTransactionSize(quint32 ui) { m_uiOutputTransactionSize = ui; } 00133 void setTransactionBegin(const QDateTime & dt) { m_dtTransactionBegin = dt; } 00134 void setTransactionRequestSent(const QDateTime & dt) { m_dtTransactionRequestSent = dt; } 00135 void setTransactionRequestReceived(const QDateTime & dt) { m_dtTransactionRequestReceived = dt; } 00136 void setTransactionReplySent(const QDateTime & dt) { m_dtTransactionReplySent = dt; } 00137 void setTransactionReplyReceived(const QDateTime & dt) { m_dtTransactionReplyReceived = dt; } 00138 void setTransactionEnd(const QDateTime & dt) { m_dtTransactionEnd = dt; } 00139 void setIpSource(const QString & s) { m_sIpSource = s; } 00140 void setIpTarget(const QString & s) { m_sIpTarget = s; } 00141 void setPortSource(long l) { m_lPortSource = l; } 00142 void setPortTarget(long l) { m_lPortTarget = l; } 00143 void setServiceName(const QString & s) { m_sServiceName = s; } 00144 void setServiceMethod(const QString & s) { m_sServiceMethod = s; } 00145 void setMessageReturn(const qx_bool & b) { m_bMessageReturn = b; } 00146 void setInputParameter(IxParameter_ptr p) { m_pInputParameter = p; } 00147 void setOutputParameter(IxParameter_ptr p) { m_pOutputParameter = p; } 00148 00149 public: 00150 00151 void executeServer(); 00152 void executeClient(IxService * pService, const QString & sMethod); 00153 00154 QString getInfos() const; 00155 00156 protected: 00157 00158 qx_bool writeSocket(QTcpSocket & socket); 00159 qx_bool readSocket(QTcpSocket & socket); 00160 00161 }; 00162 00163 typedef qx_shared_ptr<QxTransaction> QxTransaction_ptr; 00164 QX_DLL_EXPORT void execute_client(IxService * pService, const QString & sMethod); 00165 00166 } // namespace service 00167 } // namespace qx 00168 00169 QX_REGISTER_INTERNAL_HELPER_HPP(QX_DLL_EXPORT, qx::service::QxTransaction, 0) 00170 00171 #endif // _QX_SERVICE_TRANSACTION_H_ 00172 #endif // _QX_ENABLE_QT_NETWORK