QxOrm  1.4.1
C++ Object Relational Mapping library
QxConnect.h
Go to the documentation of this file.
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_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 #ifndef QX_SERVICE_DEFAULT_SERIALIZATION_TYPE
00068 #define QX_SERVICE_DEFAULT_SERIALIZATION_TYPE serialization_qt
00069 #endif // QX_SERVICE_DEFAULT_SERIALIZATION_TYPE
00070 
00071 #define QX_SERVICE_DEFAULT_ENCRYPT_KEY Q_UINT64_C(0x0f2aac3b24358a1a)
00072 
00073 namespace qx {
00074 namespace service {
00075 
00082 class QX_DLL_EXPORT QxConnect : public qx::QxSingleton<QxConnect>
00083 {
00084 
00085    friend class qx::QxSingleton<QxConnect>;
00086 
00087 public:
00088 
00089    enum serialization_type { serialization_binary, serialization_xml, serialization_text, serialization_portable_binary, 
00090                              serialization_wide_binary, serialization_wide_xml, serialization_wide_text, 
00091                              serialization_polymorphic_binary, serialization_polymorphic_xml, serialization_polymorphic_text, 
00092                              serialization_qt };
00093 
00094 protected:
00095 
00096    QString              m_sIp;                  
00097    long                 m_lPort;                
00098    serialization_type   m_eSerializationType;   
00099    long                 m_lThreadCount;         
00100    int                  m_iMaxWait;             
00101    bool                 m_bCompressData;        
00102    bool                 m_bEncryptData;         
00103    quint64              m_uiEncryptKey;         
00104 
00105 public:
00106 
00107    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; }
00108    virtual ~QxConnect();
00109 
00110    QString getIp() const                              { return m_sIp; }
00111    long getPort() const                               { return m_lPort; }
00112    serialization_type getSerializationType() const    { return m_eSerializationType; }
00113    long getThreadCount() const                        { return m_lThreadCount; }
00114    int getMaxWait() const                             { return m_iMaxWait; }
00115    bool getCompressData() const                       { return m_bCompressData; }
00116    bool getEncryptData() const                        { return m_bEncryptData; }
00117    quint64 getEncryptKey() const                      { return m_uiEncryptKey; }
00118 
00119    void setIp(const QString & s)                      { m_sIp = s; }
00120    void setPort(long l)                               { m_lPort = l; }
00121    void setSerializationType(serialization_type e)    { m_eSerializationType = e; }
00122    void setThreadCount(long l)                        { qAssert(l > 0); m_lThreadCount = l; }
00123    void setMaxWait(int i)                             { qAssert(i > 0); m_iMaxWait = i; }
00124    void setCompressData(bool b)                       { m_bCompressData = b; }
00125    void setEncryptData(bool b, quint64 key = 0)       { m_bEncryptData = b; if (key != 0) { m_uiEncryptKey = key; } }
00126 
00127 };
00128 
00129 } // namespace service
00130 } // namespace qx
00131 
00132 QX_DLL_EXPORT_QX_SINGLETON_HPP(qx::service::QxConnect)
00133 
00134 #endif // _QX_SERVICE_CONNECT_H_
00135 #endif // _QX_ENABLE_QT_NETWORK