![]() |
QxOrm
1.2.7
C++ Object Relational Mapping library
|
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 _IX_CLASS_H_ 00033 #define _IX_CLASS_H_ 00034 00035 #ifdef _MSC_VER 00036 #pragma once 00037 #endif 00038 00046 #include <typeinfo> 00047 00048 #include <QxCommon/QxPropertyBag.h> 00049 00050 #include <QxDataMember/IxDataMemberX.h> 00051 00052 #include <QxFunction/IxFunction.h> 00053 00054 #include <QxDao/QxSoftDelete.h> 00055 00056 #include <QxValidator/IxValidatorX.h> 00057 00058 namespace qx { 00059 00064 class QX_DLL_EXPORT IxClass : public qx::QxPropertyBag 00065 { 00066 00067 protected: 00068 00069 IxDataMemberX * m_pDataMemberX; 00070 IxFunctionX_ptr m_pFctMemberX; 00071 IxFunctionX_ptr m_pFctStaticX; 00072 00073 QString m_sKey; 00074 QString m_sName; 00075 QString m_sDescription; 00076 long m_lVersion; 00077 bool m_bFinalClass; 00078 bool m_bDaoReadOnly; 00079 bool m_bRegistered; 00080 qx::dao::strategy::inheritance m_eDaoStrategy; 00081 qx::QxSoftDelete m_oSoftDelete; 00082 IxValidatorX_ptr m_pAllValidator; 00083 00084 QByteArray m_byteName; 00085 const char * m_pName; 00086 00087 protected: 00088 00089 IxClass() : qx::QxPropertyBag(), m_pDataMemberX(NULL), m_lVersion(-1), m_bFinalClass(false), m_bDaoReadOnly(false), m_bRegistered(false), m_eDaoStrategy(qx::dao::strategy::concrete_table_inheritance), m_pName(NULL) { ; } 00090 virtual ~IxClass() = 0; 00091 00092 void updateClassX(); 00093 00094 public: 00095 00096 inline QString getKey() const { return m_sKey; } 00097 inline QString getName() const { return m_sName; } 00098 inline const char * getNamePtr() const { return m_pName; } 00099 inline QString getDescription() const { return m_sDescription; } 00100 inline long getVersion() const { return m_lVersion; } 00101 inline qx::dao::strategy::inheritance getDaoStrategy() const { return m_eDaoStrategy; } 00102 inline qx::QxSoftDelete getSoftDelete() const { return m_oSoftDelete; } 00103 inline bool isFinalClass() const { return m_bFinalClass; } 00104 inline bool isDaoReadOnly() const { return m_bDaoReadOnly; } 00105 inline bool isRegistered() const { return m_bRegistered; } 00106 inline IxDataMemberX * getDataMemberX() const { return m_pDataMemberX; } 00107 inline IxFunctionX * getFctMemberX() const { return m_pFctMemberX.get(); } 00108 inline IxFunctionX * getFctStaticX() const { return m_pFctStaticX.get(); } 00109 inline IxDataMember * getId() const { return (m_pDataMemberX ? m_pDataMemberX->getId() : NULL); } 00110 00111 inline void setName(const QString & sName) { m_sName = sName; updateNamePtr(); } 00112 inline void setDescription(const QString & sDesc) { m_sDescription = sDesc; } 00113 inline void setDaoStrategy(qx::dao::strategy::inheritance eDaoStrategy) { m_eDaoStrategy = eDaoStrategy; } 00114 inline void setSoftDelete(const qx::QxSoftDelete & oSoftDelete) { m_oSoftDelete = oSoftDelete; if (m_oSoftDelete.getTableName().isEmpty()) { m_oSoftDelete.setTableName(m_sName); } } 00115 inline void setDaoReadOnly(bool bDaoReadOnly) { m_bDaoReadOnly = bDaoReadOnly; } 00116 00117 virtual bool isAbstract() const = 0; 00118 virtual bool implementIxPersistable() const = 0; 00119 virtual const std::type_info & typeInfo() const = 0; 00120 virtual IxClass * getBaseClass() const = 0; 00121 virtual IxValidatorX * getAllValidator(); 00122 00123 bool isKindOf(const QString & sClassName) const; 00124 bool isKindOf(const std::type_info & typeInfo) const; 00125 QString dumpClass() const; 00126 00127 private: 00128 00129 inline void updateNamePtr() { m_byteName = m_sName.toLatin1(); m_pName = m_byteName.constData(); } 00130 00131 }; 00132 00133 typedef boost::shared_ptr<IxClass> IxClass_ptr; 00134 00135 } // namespace qx 00136 00137 #endif // _IX_CLASS_H_