![]() |
QxOrm
1.2.8
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_CONNECT_H_ 00034 #define _QX_SERVICE_CONNECT_H_ 00035 00036 #ifdef _MSC_VER 00037 #pragma once 00038 #endif 00039 00047 #include <QxSingleton/QxSingleton.h> 00048 00049 #if _QX_SERIALIZE_BINARY 00050 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_binary 00051 #elif _QX_SERIALIZE_WIDE_BINARY 00052 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_wide_binary 00053 #elif _QX_SERIALIZE_PORTABLE_BINARY 00054 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_portable_binary 00055 #elif _QX_SERIALIZE_POLYMORPHIC 00056 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_polymorphic_binary 00057 #elif _QX_SERIALIZE_TEXT 00058 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_text 00059 #elif _QX_SERIALIZE_XML 00060 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_xml 00061 #elif _QX_SERIALIZE_WIDE_TEXT 00062 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_wide_text 00063 #elif _QX_SERIALIZE_WIDE_XML 00064 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_wide_xml 00065 #endif // _QX_SERIALIZE_BINARY 00066 00067 #define QX_SERVICE_DEFAULT_ENCRYPT_KEY Q_UINT64_C(0x0f2aac3b24358a1a) 00068 00069 namespace qx { 00070 namespace service { 00071 00078 class QX_DLL_EXPORT QxConnect : public qx::QxSingleton<QxConnect> 00079 { 00080 00081 friend class qx::QxSingleton<QxConnect>; 00082 00083 public: 00084 00085 enum serialization_type { serialization_binary, serialization_xml, serialization_text, serialization_portable_binary, 00086 serialization_wide_binary, serialization_wide_xml, serialization_wide_text, 00087 serialization_polymorphic_binary, serialization_polymorphic_xml, serialization_polymorphic_text }; 00088 00089 protected: 00090 00091 QString m_sIp; 00092 long m_lPort; 00093 serialization_type m_eSerializationType; 00094 long m_lThreadCount; 00095 int m_iMaxWait; 00096 bool m_bCompressData; 00097 bool m_bEncryptData; 00098 quint64 m_uiEncryptKey; 00099 00100 public: 00101 00102 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; } 00103 virtual ~QxConnect(); 00104 00105 QString getIp() const { return m_sIp; } 00106 long getPort() const { return m_lPort; } 00107 serialization_type getSerializationType() const { return m_eSerializationType; } 00108 long getThreadCount() const { return m_lThreadCount; } 00109 int getMaxWait() const { return m_iMaxWait; } 00110 bool getCompressData() const { return m_bCompressData; } 00111 bool getEncryptData() const { return m_bEncryptData; } 00112 quint64 getEncryptKey() const { return m_uiEncryptKey; } 00113 00114 void setIp(const QString & s) { m_sIp = s; } 00115 void setPort(long l) { m_lPort = l; } 00116 void setSerializationType(serialization_type e) { m_eSerializationType = e; } 00117 void setThreadCount(long l) { qAssert(l > 0); m_lThreadCount = l; } 00118 void setMaxWait(int i) { qAssert(i > 0); m_iMaxWait = i; } 00119 void setCompressData(bool b) { m_bCompressData = b; } 00120 void setEncryptData(bool b, quint64 key = 0) { m_bEncryptData = b; if (key != 0) { m_uiEncryptKey = key; } } 00121 00122 }; 00123 00124 } // namespace service 00125 } // namespace qx 00126 00127 QX_DLL_EXPORT_QX_SINGLETON_HPP(qx::service::QxConnect) 00128 00129 #endif // _QX_SERVICE_CONNECT_H_ 00130 #endif // _QX_ENABLE_QT_NETWORK_DEPENDENCY