![]() |
QxOrm
1.2.4
C++ Object Relational Mapping library
|
00001 /**************************************************************************** 00002 ** 00003 ** http://www.qxorm.com/ 00004 ** http://sourceforge.net/projects/qxorm/ 00005 ** Original file by Lionel Marty 00006 ** 00007 ** This file is part of the QxOrm library 00008 ** 00009 ** This software is provided 'as-is', without any express or implied 00010 ** warranty. In no event will the authors be held liable for any 00011 ** damages arising from the use of this software. 00012 ** 00013 ** GNU Lesser General Public License Usage 00014 ** This file must be used under the terms of the GNU Lesser 00015 ** General Public License version 2.1 as published by the Free Software 00016 ** Foundation and appearing in the file 'license.lgpl.txt' included in the 00017 ** packaging of this file. Please review the following information to 00018 ** ensure the GNU Lesser General Public License version 2.1 requirements 00019 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 00020 ** 00021 ** If you have questions regarding the use of this file, please contact : 00022 ** contact@qxorm.com 00023 ** 00024 ****************************************************************************/ 00025 00026 #ifndef _IX_CLASS_H_ 00027 #define _IX_CLASS_H_ 00028 00029 #ifdef _MSC_VER 00030 #pragma once 00031 #endif 00032 00040 #include <typeinfo> 00041 00042 #include <QxCommon/QxPropertyBag.h> 00043 00044 #include <QxDataMember/IxDataMemberX.h> 00045 00046 #include <QxFunction/IxFunction.h> 00047 00048 #include <QxDao/QxSoftDelete.h> 00049 00050 #include <QxValidator/IxValidatorX.h> 00051 00052 namespace qx { 00053 00058 class QX_DLL_EXPORT IxClass : public qx::QxPropertyBag 00059 { 00060 00061 protected: 00062 00063 IxDataMemberX * m_pDataMemberX; 00064 IxFunctionX_ptr m_pFctMemberX; 00065 00066 QString m_sKey; 00067 QString m_sName; 00068 QString m_sDescription; 00069 long m_lVersion; 00070 bool m_bFinalClass; 00071 bool m_bDaoReadOnly; 00072 qx::dao::strategy::inheritance m_eDaoStrategy; 00073 qx::QxSoftDelete m_oSoftDelete; 00074 IxValidatorX_ptr m_pAllValidator; 00075 00076 QByteArray m_byteName; 00077 const char * m_pName; 00078 00079 protected: 00080 00081 IxClass() : qx::QxPropertyBag(), m_pDataMemberX(NULL), m_lVersion(-1), m_bFinalClass(false), m_bDaoReadOnly(false), m_eDaoStrategy(qx::dao::strategy::concrete_table_inheritance), m_pName(NULL) { ; } 00082 virtual ~IxClass() = 0; 00083 00084 void updateClassX(); 00085 00086 public: 00087 00088 inline QString getKey() const { return m_sKey; } 00089 inline QString getName() const { return m_sName; } 00090 inline const char * getNamePtr() const { return m_pName; } 00091 inline QString getDescription() const { return m_sDescription; } 00092 inline long getVersion() const { return m_lVersion; } 00093 inline qx::dao::strategy::inheritance getDaoStrategy() const { return m_eDaoStrategy; } 00094 inline qx::QxSoftDelete getSoftDelete() const { return m_oSoftDelete; } 00095 inline bool isFinalClass() const { return m_bFinalClass; } 00096 inline bool isDaoReadOnly() const { return m_bDaoReadOnly; } 00097 inline IxDataMemberX * getDataMemberX() const { return m_pDataMemberX; } 00098 inline IxFunctionX * getFctMemberX() const { return m_pFctMemberX.get(); } 00099 inline IxDataMember * getId() const { return (m_pDataMemberX ? m_pDataMemberX->getId() : NULL); } 00100 00101 inline void setName(const QString & sName) { m_sName = sName; updateNamePtr(); } 00102 inline void setDescription(const QString & sDesc) { m_sDescription = sDesc; } 00103 inline void setDaoStrategy(qx::dao::strategy::inheritance eDaoStrategy) { m_eDaoStrategy = eDaoStrategy; } 00104 inline void setSoftDelete(const qx::QxSoftDelete & oSoftDelete) { m_oSoftDelete = oSoftDelete; if (m_oSoftDelete.getTableName().isEmpty()) { m_oSoftDelete.setTableName(m_sName); } } 00105 inline void setDaoReadOnly(bool bDaoReadOnly) { m_bDaoReadOnly = bDaoReadOnly; } 00106 00107 virtual bool isAbstract() const = 0; 00108 virtual bool implementIxPersistable() const = 0; 00109 virtual const std::type_info & typeInfo() const = 0; 00110 virtual IxClass * getBaseClass() const = 0; 00111 virtual IxValidatorX * getAllValidator(); 00112 00113 bool isKindOf(const QString & sClassName) const; 00114 bool isKindOf(const std::type_info & typeInfo) const; 00115 QString dumpClass() const; 00116 00117 private: 00118 00119 inline void updateNamePtr() { m_byteName = m_sName.toAscii(); m_pName = m_byteName.constData(); } 00120 00121 }; 00122 00123 typedef boost::shared_ptr<IxClass> IxClass_ptr; 00124 00125 } // namespace qx 00126 00127 #endif // _IX_CLASS_H_