QxOrm  1.4.5
C++ Object Relational Mapping library
QxDataMember_QObject.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 #ifndef _QX_DATA_MEMBER_QOBJECT_H_
00033 #define _QX_DATA_MEMBER_QOBJECT_H_
00034 
00035 #ifdef _MSC_VER
00036 #pragma once
00037 #endif
00038 
00046 #include <QtCore/qmetaobject.h>
00047 #include <QtCore/qmetatype.h>
00048 
00049 #include <QxDataMember/IxDataMember.h>
00050 
00051 #include <QxSerialize/Qt/QxSerialize_QString.h>
00052 #include <QxSerialize/Qt/QxSerialize_QVariant.h>
00053 
00054 #define QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(ArchiveInput, ArchiveOutput) \
00055 virtual void toArchive(const void * pOwner, ArchiveOutput & ar) const; \
00056 virtual void fromArchive(void * pOwner, ArchiveInput & ar);
00057 
00058 namespace qx {
00059 
00064 class QX_DLL_EXPORT QxDataMember_QObject : public IxDataMember
00065 {
00066 
00067 protected:
00068 
00069    const QMetaObject *  m_metaObject;    
00070    QMetaProperty        m_metaProperty;  
00071 
00072 public:
00073 
00074    QxDataMember_QObject(const QMetaObject * pMetaObject, const QString & sKey);
00075    virtual ~QxDataMember_QObject() { ; }
00076 
00077    virtual bool isEqual(const void * pOwner1, const void * pOwner2) const;
00078    virtual QString toString(const void * pOwner, const QString & sFormat, int iIndexName = -1) const;
00079    virtual qx_bool fromString(void * pOwner, const QString & s, const QString & sFormat, int iIndexName = -1);
00080    virtual QVariant toVariant(const void * pOwner, const QString & sFormat, int iIndexName = -1, qx::cvt::context::ctx_type ctx = qx::cvt::context::e_no_context) const;
00081    virtual qx_bool fromVariant(void * pOwner, const QVariant & v, const QString & sFormat, int iIndexName = -1, qx::cvt::context::ctx_type ctx = qx::cvt::context::e_no_context);
00082    virtual QString getType() const;
00083 
00084 #ifndef _QX_NO_JSON
00085    virtual QJsonValue toJson(const void * pOwner, const QString & sFormat) const;
00086    virtual qx_bool fromJson(void * pOwner, const QJsonValue & j, const QString & sFormat);
00087 #endif // _QX_NO_JSON
00088 
00089 public:
00090 
00091 #ifdef _QX_ENABLE_BOOST_SERIALIZATION
00092 
00093 #if _QX_SERIALIZE_POLYMORPHIC
00094    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::polymorphic_iarchive, boost::archive::polymorphic_oarchive)
00095 #endif // _QX_SERIALIZE_POLYMORPHIC
00096 
00097 #if _QX_SERIALIZE_BINARY
00098    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::binary_iarchive, boost::archive::binary_oarchive)
00099 #endif // _QX_SERIALIZE_BINARY
00100 
00101 #if _QX_SERIALIZE_TEXT
00102    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::text_iarchive, boost::archive::text_oarchive)
00103 #endif // _QX_SERIALIZE_TEXT
00104 
00105 #if _QX_SERIALIZE_XML
00106    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::xml_iarchive, boost::archive::xml_oarchive)
00107 #endif // _QX_SERIALIZE_XML
00108 
00109 #if _QX_SERIALIZE_PORTABLE_BINARY
00110    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(eos::portable_iarchive, eos::portable_oarchive)
00111 #endif // _QX_SERIALIZE_PORTABLE_BINARY
00112 
00113 #if _QX_SERIALIZE_WIDE_BINARY
00114    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::binary_wiarchive, boost::archive::binary_woarchive)
00115 #endif // _QX_SERIALIZE_WIDE_BINARY
00116 
00117 #if _QX_SERIALIZE_WIDE_TEXT
00118    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::text_wiarchive, boost::archive::text_woarchive)
00119 #endif // _QX_SERIALIZE_WIDE_TEXT
00120 
00121 #if _QX_SERIALIZE_WIDE_XML
00122    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::xml_wiarchive, boost::archive::xml_woarchive)
00123 #endif // _QX_SERIALIZE_WIDE_XML
00124 
00125 #endif // _QX_ENABLE_BOOST_SERIALIZATION
00126 
00127 protected:
00128 
00129    virtual qx::any getDataPtr(const void * pOwner) const;
00130    virtual qx::any getDataPtr(void * pOwner);
00131    virtual void * getDataVoidPtr(const void * pOwner) const;
00132    virtual void * getDataVoidPtr(void * pOwner);
00133 
00134 };
00135 
00136 } // namespace qx
00137 
00138 #endif // _QX_DATA_MEMBER_QOBJECT_H_