QxOrm  1.5.0
C++ Object Relational Mapping library
IxService.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** https://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 _IX_SERVICE_H_
00034 #define _IX_SERVICE_H_
00035 
00036 #ifdef _MSC_VER
00037 #pragma once
00038 #endif
00039 
00047 #include <QtCore/qdatastream.h>
00048 
00049 #ifndef _QX_NO_JSON
00050 #include <QtCore/qjsonvalue.h>
00051 #endif // _QX_NO_JSON
00052 
00053 #include <QxCommon/QxBool.h>
00054 
00055 #include <QxRegister/QxRegisterInternalHelper.h>
00056 
00057 #include <QxService/IxParameter.h>
00058 
00059 #include <QxConvert/QxConvert.h>
00060 
00061 namespace qx {
00062 namespace service {
00063 class QxTransaction;
00064 class IxService;
00065 } // namespace service
00066 } // namespace qx
00067 
00068 QX_DLL_EXPORT QDataStream & operator<< (QDataStream & stream, const qx::service::IxService & t) QX_USED;
00069 QX_DLL_EXPORT QDataStream & operator>> (QDataStream & stream, qx::service::IxService & t) QX_USED;
00070 
00071 #ifndef _QX_NO_JSON
00072 namespace qx {
00073 namespace cvt {
00074 namespace detail {
00075 template <> struct QxConvert_ToJson< qx::service::IxService >;
00076 template <> struct QxConvert_FromJson< qx::service::IxService >;
00077 QX_DLL_EXPORT QJsonValue QxConvert_ToJson_Helper(const qx::service::IxService & t, const QString & format) QX_USED;
00078 QX_DLL_EXPORT qx_bool QxConvert_FromJson_Helper(const QJsonValue & j, qx::service::IxService & t, const QString & format) QX_USED;
00079 } // namespace detail
00080 } // namespace cvt
00081 } // namespace qx
00082 #endif // _QX_NO_JSON
00083 
00084 namespace qx {
00085 namespace service {
00086 
00093 class QX_DLL_EXPORT IxService
00094 {
00095 
00096    friend QX_DLL_EXPORT QDataStream & ::operator<< (QDataStream & stream, const qx::service::IxService & t);
00097    friend QX_DLL_EXPORT QDataStream & ::operator>> (QDataStream & stream, qx::service::IxService & t);
00098 
00099 #ifndef _QX_NO_JSON
00100    friend struct qx::cvt::detail::QxConvert_ToJson< qx::service::IxService >;
00101    friend struct qx::cvt::detail::QxConvert_FromJson< qx::service::IxService >;
00102    friend QX_DLL_EXPORT QJsonValue qx::cvt::detail::QxConvert_ToJson_Helper(const qx::service::IxService & t, const QString & format);
00103    friend QX_DLL_EXPORT qx_bool qx::cvt::detail::QxConvert_FromJson_Helper(const QJsonValue & j, qx::service::IxService & t, const QString & format);
00104 #endif // _QX_NO_JSON
00105 
00106 protected:
00107 
00108    QString m_sServiceName;                            
00109    QString m_sServiceMethodName;                      
00110    IxParameter_ptr m_pInputParameter;                 
00111    IxParameter_ptr m_pOutputParameter;                
00112    qx_bool m_bMessageReturn;                          
00113    std::shared_ptr<QxTransaction> m_pTransaction;     
00114 
00115 public:
00116 
00117    IxService();
00118    IxService(const QString & sServiceName);
00119    virtual ~IxService();
00120 
00121    QString getServiceName() const                              { return m_sServiceName; }
00122    QString getServiceMethodName() const                        { return m_sServiceMethodName; }
00123    IxParameter_ptr getInputParameter_BaseClass() const         { return m_pInputParameter; }
00124    IxParameter_ptr getOutputParameter_BaseClass() const        { return m_pOutputParameter; }
00125    qx_bool getMessageReturn() const                            { return m_bMessageReturn; }
00126    std::shared_ptr<QxTransaction> getTransaction() const;
00127 
00128    void setServiceName(const QString & s)                               { qAssert(! s.isEmpty()); m_sServiceName = s; }
00129    void setServiceMethodName(const QString & s)                         { qAssert(! s.isEmpty()); m_sServiceMethodName = s; }
00130    void setInputParameter(IxParameter_ptr p)                            { m_pInputParameter = p; }
00131    void setOutputParameter(IxParameter_ptr p)                           { m_pOutputParameter = p; }
00132    void setMessageReturn(const qx_bool & b)                             { m_bMessageReturn = b; }
00133    void setMessageReturn(long l, const QString & s)                     { m_bMessageReturn = qx_bool(l, s); }
00134    void setTransaction(const std::shared_ptr<QxTransaction> & p);
00135 
00136    bool isValid() const             { return m_bMessageReturn.getValue(); }
00137    bool isValidWithOutput() const   { return (isValid() && (m_pOutputParameter.get() != NULL)); }
00138 
00139    virtual void registerClass() const  { qDebug("[QxOrm] qx::service::IxService : %s", "need to override 'registerClass()' method"); qAssert(false); }
00140    virtual void onBeforeProcess()      { ; }
00141    virtual void onAfterProcess()       { ; }
00142 
00143 };
00144 
00145 typedef std::shared_ptr<IxService> IxService_ptr;
00146 
00147 } // namespace service
00148 } // namespace qx
00149 
00150 QX_REGISTER_INTERNAL_HELPER_HPP(QX_DLL_EXPORT, qx::service::IxService, 0)
00151 
00152 #endif // _IX_SERVICE_H_
00153 #endif // _QX_ENABLE_QT_NETWORK