![]() |
QxOrm
1.2.3
C++ Object Relational Mapping library
|
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 #if _QX_ENABLE_QT_NETWORK_DEPENDENCY 00027 #ifndef _QX_SERVICE_CONNECT_H_ 00028 #define _QX_SERVICE_CONNECT_H_ 00029 00030 #ifdef _MSC_VER 00031 #pragma once 00032 #endif 00033 00041 #include <QxSingleton/QxSingleton.h> 00042 00043 #if _QX_SERIALIZE_BINARY 00044 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_binary 00045 #elif _QX_SERIALIZE_WIDE_BINARY 00046 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_wide_binary 00047 #elif _QX_SERIALIZE_PORTABLE_BINARY 00048 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_portable_binary 00049 #elif _QX_SERIALIZE_POLYMORPHIC 00050 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_polymorphic_binary 00051 #elif _QX_SERIALIZE_TEXT 00052 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_text 00053 #elif _QX_SERIALIZE_XML 00054 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_xml 00055 #elif _QX_SERIALIZE_WIDE_TEXT 00056 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_wide_text 00057 #elif _QX_SERIALIZE_WIDE_XML 00058 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_wide_xml 00059 #endif // _QX_SERIALIZE_BINARY 00060 00061 #define QX_SERVICE_DEFAULT_ENCRYPT_KEY Q_UINT64_C(0x0f2aac3b24358a1a) 00062 00063 namespace qx { 00064 namespace service { 00065 00072 class QX_DLL_EXPORT QxConnect : public qx::QxSingleton<QxConnect> 00073 { 00074 00075 friend class qx::QxSingleton<QxConnect>; 00076 00077 public: 00078 00079 enum serialization_type { serialization_binary, serialization_xml, serialization_text, serialization_portable_binary, 00080 serialization_wide_binary, serialization_wide_xml, serialization_wide_text, 00081 serialization_polymorphic_binary, serialization_polymorphic_xml, serialization_polymorphic_text }; 00082 00083 protected: 00084 00085 QString m_sIp; 00086 long m_lPort; 00087 serialization_type m_eSerializationType; 00088 long m_lThreadCount; 00089 int m_iMaxWait; 00090 bool m_bCompressData; 00091 bool m_bEncryptData; 00092 quint64 m_uiEncryptKey; 00093 00094 public: 00095 00096 QxConnect() : qx::QxSingleton<QxConnect>("qx::service::QxConnect"), m_lPort(0), m_eSerializationType(QX_SERVICE_DEFAULT_SERIALIZATION_TYPE), m_lThreadCount(30), m_iMaxWait(30000), m_bCompressData(false), m_bEncryptData(false) { m_uiEncryptKey = QX_SERVICE_DEFAULT_ENCRYPT_KEY; } 00097 virtual ~QxConnect(); 00098 00099 QString getIp() const { return m_sIp; } 00100 long getPort() const { return m_lPort; } 00101 serialization_type getSerializationType() const { return m_eSerializationType; } 00102 long getThreadCount() const { return m_lThreadCount; } 00103 int getMaxWait() const { return m_iMaxWait; } 00104 bool getCompressData() const { return m_bCompressData; } 00105 bool getEncryptData() const { return m_bEncryptData; } 00106 quint64 getEncryptKey() const { return m_uiEncryptKey; } 00107 00108 void setIp(const QString & s) { m_sIp = s; } 00109 void setPort(long l) { m_lPort = l; } 00110 void setSerializationType(serialization_type e) { m_eSerializationType = e; } 00111 void setThreadCount(long l) { qAssert(l > 0); m_lThreadCount = l; } 00112 void setMaxWait(int i) { qAssert(i > 0); m_iMaxWait = i; } 00113 void setCompressData(bool b) { m_bCompressData = b; } 00114 void setEncryptData(bool b, quint64 key = 0) { m_bEncryptData = b; if (key != 0) { m_uiEncryptKey = key; } } 00115 00116 }; 00117 00118 } // namespace service 00119 } // namespace qx 00120 00121 QX_DLL_EXPORT_QX_SINGLETON_HPP(qx::service::QxConnect) 00122 00123 #endif // _QX_SERVICE_CONNECT_H_ 00124 #endif // _QX_ENABLE_QT_NETWORK_DEPENDENCY