QxOrm  1.2.9
C++ Object Relational Mapping library
QxDataMember_QObject.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** http://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) const;
00081    virtual qx_bool fromVariant(void * pOwner, const QVariant & v, const QString & sFormat, int iIndexName = -1);
00082 
00083 public:
00084 
00085 #if _QX_SERIALIZE_POLYMORPHIC
00086    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::polymorphic_iarchive, boost::archive::polymorphic_oarchive)
00087 #endif // _QX_SERIALIZE_POLYMORPHIC
00088 
00089 #if _QX_SERIALIZE_BINARY
00090    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::binary_iarchive, boost::archive::binary_oarchive)
00091 #endif // _QX_SERIALIZE_BINARY
00092 
00093 #if _QX_SERIALIZE_TEXT
00094    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::text_iarchive, boost::archive::text_oarchive)
00095 #endif // _QX_SERIALIZE_TEXT
00096 
00097 #if _QX_SERIALIZE_XML
00098    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::xml_iarchive, boost::archive::xml_oarchive)
00099 #endif // _QX_SERIALIZE_XML
00100 
00101 #if _QX_SERIALIZE_PORTABLE_BINARY
00102    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(eos::portable_iarchive, eos::portable_oarchive)
00103 #endif // _QX_SERIALIZE_PORTABLE_BINARY
00104 
00105 #if _QX_SERIALIZE_WIDE_BINARY
00106    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::binary_wiarchive, boost::archive::binary_woarchive)
00107 #endif // _QX_SERIALIZE_WIDE_BINARY
00108 
00109 #if _QX_SERIALIZE_WIDE_TEXT
00110    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::text_wiarchive, boost::archive::text_woarchive)
00111 #endif // _QX_SERIALIZE_WIDE_TEXT
00112 
00113 #if _QX_SERIALIZE_WIDE_XML
00114    QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::xml_wiarchive, boost::archive::xml_woarchive)
00115 #endif // _QX_SERIALIZE_WIDE_XML
00116 
00117 protected:
00118 
00119    virtual boost::any getDataPtr(const void * pOwner) const;
00120    virtual boost::any getDataPtr(void * pOwner);
00121    virtual void * getDataVoidPtr(const void * pOwner) const;
00122    virtual void * getDataVoidPtr(void * pOwner);
00123 
00124 };
00125 
00126 } // namespace qx
00127 
00128 #endif // _QX_DATA_MEMBER_QOBJECT_H_