QxOrm  1.4.5
C++ Object Relational Mapping library
IxParameter.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_PARAMETER_H_
00034 #define _IX_SERVICE_PARAMETER_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 <QxRegister/QxRegisterInternalHelper.h>
00054 
00055 namespace qx {
00056 namespace service {
00057 class IxParameter;
00058 } // namespace service
00059 } // namespace qx
00060 
00061 QX_DLL_EXPORT QDataStream & operator<< (QDataStream & stream, const qx::service::IxParameter & t) QX_USED;
00062 QX_DLL_EXPORT QDataStream & operator>> (QDataStream & stream, qx::service::IxParameter & t) QX_USED;
00063 
00064 namespace qx {
00065 namespace service {
00066 
00073 class QX_DLL_EXPORT IxParameter
00074 {
00075 
00076    friend QX_DLL_EXPORT QDataStream & ::operator<< (QDataStream & stream, const qx::service::IxParameter & t);
00077    friend QX_DLL_EXPORT QDataStream & ::operator>> (QDataStream & stream, qx::service::IxParameter & t);
00078 
00079 public:
00080 
00081    IxParameter();
00082    virtual ~IxParameter();
00083 
00084    // Need to override these methods only if you are using 'qx::service::QxConnect::serialization_qt' type (based on QDataStream) or 'qx::service::QxConnect::serialization_json' type (based on QJson engine)
00085    // You can use QX_SERVICE_IX_PARAMETER_SERIALIZATION_HPP and QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP macro to override
00086    virtual void registerClass() const;
00087    virtual QString getClassName() const;
00088    virtual void save(QDataStream & stream) const;
00089    virtual void load(QDataStream & stream);
00090 
00091 #ifndef _QX_NO_JSON
00092    virtual QJsonValue saveToJson() const;
00093    virtual qx_bool loadFromJson(const QJsonValue & val);
00094 #endif // _QX_NO_JSON
00095 
00096 };
00097 
00098 typedef std::shared_ptr<IxParameter> IxParameter_ptr;
00099 
00100 } // namespace service
00101 } // namespace qx
00102 
00103 QX_REGISTER_INTERNAL_HELPER_HPP(QX_DLL_EXPORT, qx::service::IxParameter, 0)
00104 
00105 #define QX_SERVICE_IX_PARAMETER_QDATASTREAM_HPP(className) \
00106 public: \
00107 virtual void save(QDataStream & stream) const; \
00108 virtual void load(QDataStream & stream);
00109 
00110 #define QX_SERVICE_IX_PARAMETER_QDATASTREAM_CPP(className) \
00111 void className::save(QDataStream & stream) const { qx::QxSerializeRegistered< className >::save(stream, (* this)); } \
00112 void className::load(QDataStream & stream) { qx::QxSerializeRegistered< className >::load(stream, (* this)); }
00113 
00114 #ifndef _QX_NO_JSON
00115 
00116 #define QX_SERVICE_IX_PARAMETER_QJSON_HPP(className) \
00117 public: \
00118 virtual QJsonValue saveToJson() const; \
00119 virtual qx_bool loadFromJson(const QJsonValue & val);
00120 
00121 #define QX_SERVICE_IX_PARAMETER_QJSON_CPP(className) \
00122 QJsonValue className::saveToJson() const { return qx::cvt::detail::QxSerializeJsonRegistered< className >::save((* this), ""); } \
00123 qx_bool className::loadFromJson(const QJsonValue & val) { return qx::cvt::detail::QxSerializeJsonRegistered< className >::load(val, (* this), ""); }
00124 
00125 #else // _QX_NO_JSON
00126 #define QX_SERVICE_IX_PARAMETER_QJSON_HPP(className) /* Nothing */
00127 #define QX_SERVICE_IX_PARAMETER_QJSON_CPP(className) /* Nothing */
00128 #endif // _QX_NO_JSON
00129 
00130 #define QX_SERVICE_IX_PARAMETER_SERIALIZATION_HPP(className) \
00131 QX_SERVICE_IX_PARAMETER_QDATASTREAM_HPP(className) \
00132 QX_SERVICE_IX_PARAMETER_QJSON_HPP(className) \
00133 public: \
00134 virtual void registerClass() const; \
00135 virtual QString getClassName() const;
00136 
00137 #define QX_SERVICE_IX_PARAMETER_SERIALIZATION_CPP(className) \
00138 QX_SERVICE_IX_PARAMETER_QDATASTREAM_CPP(className) \
00139 QX_SERVICE_IX_PARAMETER_QJSON_CPP(className) \
00140 void className::registerClass() const { qx::QxClass< className >::getSingleton(); } \
00141 QString className::getClassName() const { return #className; }
00142 
00143 #endif // _IX_SERVICE_PARAMETER_H_
00144 #endif // _QX_ENABLE_QT_NETWORK