QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
IxService.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** https://www.qxorm.com/
4** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
5**
6** This file is part of the QxOrm library
7**
8** This software is provided 'as-is', without any express or implied
9** warranty. In no event will the authors be held liable for any
10** damages arising from the use of this software
11**
12** Commercial Usage
13** Licensees holding valid commercial QxOrm licenses may use this file in
14** accordance with the commercial license agreement provided with the
15** Software or, alternatively, in accordance with the terms contained in
16** a written agreement between you and Lionel Marty
17**
18** GNU General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU
20** General Public License version 3.0 as published by the Free Software
21** Foundation and appearing in the file 'license.gpl3.txt' included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU General Public License version 3.0 requirements will be
24** met : http://www.gnu.org/copyleft/gpl.html
25**
26** If you are unsure which license is appropriate for your use, or
27** if you have questions regarding the use of this file, please contact :
28** contact@qxorm.com
29**
30****************************************************************************/
31
32#ifdef _QX_ENABLE_QT_NETWORK
33#ifndef _IX_SERVICE_H_
34#define _IX_SERVICE_H_
35
36#ifdef _MSC_VER
37#pragma once
38#endif
39
47#include <QtCore/qdatastream.h>
48
49#ifndef _QX_NO_JSON
50#include <QtCore/qjsonvalue.h>
51#endif // _QX_NO_JSON
52
53#include <QxCommon/QxBool.h>
54
56
58
59#include <QxConvert/QxConvert.h>
60
61namespace qx {
62namespace service {
63class QxTransaction;
64class IxService;
65} // namespace service
66} // namespace qx
67
68QX_DLL_EXPORT QDataStream & operator<< (QDataStream & stream, const qx::service::IxService & t) QX_USED;
69QX_DLL_EXPORT QDataStream & operator>> (QDataStream & stream, qx::service::IxService & t) QX_USED;
70
71#ifndef _QX_NO_JSON
72namespace qx {
73namespace cvt {
74namespace detail {
75template <> struct QxConvert_ToJson< qx::service::IxService >;
76template <> struct QxConvert_FromJson< qx::service::IxService >;
77QX_DLL_EXPORT QJsonValue QxConvert_ToJson_Helper(const qx::service::IxService & t, const QString & format) QX_USED;
78QX_DLL_EXPORT qx_bool QxConvert_FromJson_Helper(const QJsonValue & j, qx::service::IxService & t, const QString & format) QX_USED;
79} // namespace detail
80} // namespace cvt
81} // namespace qx
82#endif // _QX_NO_JSON
83
84namespace qx {
85namespace service {
86
94{
95
96 friend QX_DLL_EXPORT QDataStream & ::operator<< (QDataStream & stream, const qx::service::IxService & t);
97 friend QX_DLL_EXPORT QDataStream & ::operator>> (QDataStream & stream, qx::service::IxService & t);
98
99#ifndef _QX_NO_JSON
101 friend struct qx::cvt::detail::QxConvert_FromJson< qx::service::IxService >;
102 friend QX_DLL_EXPORT QJsonValue qx::cvt::detail::QxConvert_ToJson_Helper(const qx::service::IxService & t, const QString & format);
103 friend QX_DLL_EXPORT qx_bool qx::cvt::detail::QxConvert_FromJson_Helper(const QJsonValue & j, qx::service::IxService & t, const QString & format);
104#endif // _QX_NO_JSON
105
106protected:
107
108 QString m_sServiceName;
109 QString m_sServiceMethodName;
110 IxParameter_ptr m_pInputParameter;
111 IxParameter_ptr m_pOutputParameter;
112 qx_bool m_bMessageReturn;
113 std::shared_ptr<QxTransaction> m_pTransaction;
114
115public:
116
118 IxService(const QString & sServiceName);
119 virtual ~IxService();
120
121 QString getServiceName() const { return m_sServiceName; }
122 QString getServiceMethodName() const { return m_sServiceMethodName; }
123 IxParameter_ptr getInputParameter_BaseClass() const { return m_pInputParameter; }
124 IxParameter_ptr getOutputParameter_BaseClass() const { return m_pOutputParameter; }
125 qx_bool getMessageReturn() const { return m_bMessageReturn; }
126 std::shared_ptr<QxTransaction> getTransaction() const;
127
128 void setServiceName(const QString & s) { qAssert(! s.isEmpty()); m_sServiceName = s; }
129 void setServiceMethodName(const QString & s) { qAssert(! s.isEmpty()); m_sServiceMethodName = s; }
130 void setInputParameter(IxParameter_ptr p) { m_pInputParameter = p; }
131 void setOutputParameter(IxParameter_ptr p) { m_pOutputParameter = p; }
132 void setMessageReturn(const qx_bool & b) { m_bMessageReturn = b; }
133 void setMessageReturn(long l, const QString & s) { m_bMessageReturn = qx_bool(l, s); }
134 void setTransaction(const std::shared_ptr<QxTransaction> & p);
135
136 bool isValid() const { return m_bMessageReturn.getValue(); }
137 bool isValidWithOutput() const { return (isValid() && (m_pOutputParameter.get() != NULL)); }
138
139 virtual void registerClass() const { qDebug("[QxOrm] qx::service::IxService : %s", "need to override 'registerClass()' method"); qAssert(false); }
140 virtual void onBeforeProcess() { ; }
141 virtual void onAfterProcess() { ; }
142
143};
144
145typedef std::shared_ptr<IxService> IxService_ptr;
146
147} // namespace service
148} // namespace qx
149
151
152#endif // _IX_SERVICE_H_
153#endif // _QX_ENABLE_QT_NETWORK
Common interface for all parameters transfered by QxService module of QxOrm library.
QX_DLL_EXPORT QDataStream & operator<<(QDataStream &stream, const qx::service::IxService &t) QX_USED
QX_DLL_EXPORT QDataStream & operator>>(QDataStream &stream, qx::service::IxService &t) QX_USED
qx_bool : QxOrm library boolean type with code and description message when an error occured
qx::QxBool qx_bool
Definition QxBool.h:150
qx::cvt : namespace to provide global functions to convert any kind of objects to/from QString and QV...
#define QX_USED
Definition QxMacro.h:244
#define qAssert(x)
Definition QxMacro.h:52
#define QX_DLL_EXPORT
Definition QxMacro.h:182
#define QX_REGISTER_INTERNAL_HELPER_HPP(dllImportExport, className, version)
qx_bool : boolean type with code and description message when an error occured
Definition QxBool.h:71
qx::service::IxService : common interface for all services defined with QxService module of QxOrm lib...
Definition IxService.h:94
virtual void onAfterProcess()
Definition IxService.h:141
QString getServiceMethodName() const
Definition IxService.h:122
bool isValid() const
Definition IxService.h:136
void setServiceMethodName(const QString &s)
Definition IxService.h:129
virtual void registerClass() const
Definition IxService.h:139
virtual void onBeforeProcess()
Definition IxService.h:140
IxParameter_ptr getInputParameter_BaseClass() const
Definition IxService.h:123
void setServiceName(const QString &s)
Definition IxService.h:128
void setMessageReturn(const qx_bool &b)
Definition IxService.h:132
bool isValidWithOutput() const
Definition IxService.h:137
void setOutputParameter(IxParameter_ptr p)
Definition IxService.h:131
void setInputParameter(IxParameter_ptr p)
Definition IxService.h:130
void setMessageReturn(long l, const QString &s)
Definition IxService.h:133
IxParameter_ptr getOutputParameter_BaseClass() const
Definition IxService.h:124
std::shared_ptr< QxTransaction > getTransaction() const
qx_bool getMessageReturn() const
Definition IxService.h:125
void setTransaction(const std::shared_ptr< QxTransaction > &p)
QX_DLL_EXPORT QJsonValue QxConvert_ToJson_Helper(const qx::dao::detail::IxSqlElement &t, const QString &format) QX_USED
QX_DLL_EXPORT qx_bool QxConvert_FromJson_Helper(const QJsonValue &j, qx::dao::detail::IxSqlElement &t, const QString &format) QX_USED
std::shared_ptr< IxParameter > IxParameter_ptr
Definition IxParameter.h:98
std::shared_ptr< IxService > IxService_ptr
Definition IxService.h:145
Root namespace for all QxOrm library features.