QxOrm  1.4.9
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 QVariant toVariant(const void * pOwner, const QString & sFormat, int iIndexName = -1, qx::cvt::context::ctx_type ctx = qx::cvt::context::e_no_context) const;
00079    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);
00080    virtual QString getType() const;
00081 
00082 #ifndef _QX_NO_JSON
00083    virtual QJsonValue toJson(const void * pOwner, const QString & sFormat) const;
00084    virtual qx_bool fromJson(void * pOwner, const QJsonValue & j, const QString & sFormat);
00085 #endif // _QX_NO_JSON
00086 
00087 public:
00088 
00089 #ifdef _QX_ENABLE_BOOST_SERIALIZATION
00090 
00091 #if _QX_SERIALIZE_POLYMORPHIC
00092    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::polymorphic_iarchive, boost::archive::polymorphic_oarchive)
00093 #endif // _QX_SERIALIZE_POLYMORPHIC
00094 
00095 #if _QX_SERIALIZE_BINARY
00096    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::binary_iarchive, boost::archive::binary_oarchive)
00097 #endif // _QX_SERIALIZE_BINARY
00098 
00099 #if _QX_SERIALIZE_TEXT
00100    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::text_iarchive, boost::archive::text_oarchive)
00101 #endif // _QX_SERIALIZE_TEXT
00102 
00103 #if _QX_SERIALIZE_XML
00104    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::xml_iarchive, boost::archive::xml_oarchive)
00105 #endif // _QX_SERIALIZE_XML
00106 
00107 #if _QX_SERIALIZE_PORTABLE_BINARY
00108    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(eos::portable_iarchive, eos::portable_oarchive)
00109 #endif // _QX_SERIALIZE_PORTABLE_BINARY
00110 
00111 #if _QX_SERIALIZE_WIDE_BINARY
00112    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::binary_wiarchive, boost::archive::binary_woarchive)
00113 #endif // _QX_SERIALIZE_WIDE_BINARY
00114 
00115 #if _QX_SERIALIZE_WIDE_TEXT
00116    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::text_wiarchive, boost::archive::text_woarchive)
00117 #endif // _QX_SERIALIZE_WIDE_TEXT
00118 
00119 #if _QX_SERIALIZE_WIDE_XML
00120    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::xml_wiarchive, boost::archive::xml_woarchive)
00121 #endif // _QX_SERIALIZE_WIDE_XML
00122 
00123 #endif // _QX_ENABLE_BOOST_SERIALIZATION
00124 
00125 protected:
00126 
00127    virtual qx::any getDataPtr(const void * pOwner) const;
00128    virtual qx::any getDataPtr(void * pOwner);
00129    virtual void * getDataVoidPtr(const void * pOwner) const;
00130    virtual void * getDataVoidPtr(void * pOwner);
00131 
00132 };
00133 
00134 } // namespace qx
00135 
00136 #endif // _QX_DATA_MEMBER_QOBJECT_H_