Class hierarchy

Forum for posting problems using QxOrm library

Class hierarchy

Postby ruddy32 » Fri Jan 07, 2011 10:30 am

Hi,
Is it possible to use QxOrm with class hierarchy, like having a base class use for all my derived entity classes?
The target is to implement generic method in the base class (insert, update, xml read, xml write, etc). How to do that ?
Thanks
ruddy32
 

Re: Class hierarchy

Postby ruddy32 » Fri Jan 07, 2011 3:35 pm

I update my source code compare to the CUser/Cperson example.
Linking process give the following error :
undefined reference to `typeinfo for pack::MyClass'

Any idea?
ruddy32
 

Re: Class hierarchy

Postby QxOrm admin » Fri Jan 07, 2011 3:50 pm

I don't understand your request (???).
Please, post an example and/or source code...
QxOrm admin
 

Re: Class hierarchy

Postby ruddy32 » Fri Jan 07, 2011 4:12 pm

Base class header
Code: Select all
#ifdef _BUILDING_DLL
#define QX_DLL_EXPORT QX_DLL_EXPORT_HELPER
#else // _BUILDING_DLL
#define QX_DLL_EXPORT QX_DLL_IMPORT_HELPER
#endif // _BUILDING_DLL
#ifdef _BUILDING_DLL
#define QX_REGISTER_HPP_DLL QX_REGISTER_HPP_EXPORT_DLL
#define QX_REGISTER_CPP_DLL QX_REGISTER_CPP_EXPORT_DLL
#define QX_REGISTER_COMPLEX_CLASS_NAME_HPP_DLL QX_REGISTER_COMPLEX_CLASS_NAME_HPP_EXPORT_DLL
#define QX_REGISTER_COMPLEX_CLASS_NAME_CPP_DLL QX_REGISTER_COMPLEX_CLASS_NAME_CPP_EXPORT_DLL
#else // _BUILDING_DLL
#define QX_REGISTER_HPP_DLL QX_REGISTER_HPP_IMPORT_DLL
#define QX_REGISTER_CPP_DLL QX_REGISTER_CPP_IMPORT_DLL
#define QX_REGISTER_COMPLEX_CLASS_NAME_HPP_DLL QX_REGISTER_COMPLEX_CLASS_NAME_HPP_IMPORT_DLL
#define QX_REGISTER_COMPLEX_CLASS_NAME_CPP_DLL QX_REGISTER_COMPLEX_CLASS_NAME_CPP_IMPORT_DLL
#endif // _BUILDING_DLL
#define QX_APP_EXPORT QX_DLL_EXPORT_HELPER
#define QX_REGISTER_HPP_APP QX_REGISTER_HPP_EXPORT_DLL
#define QX_REGISTER_CPP_APP QX_REGISTER_CPP_EXPORT_DLL
#define QX_REGISTER_COMPLEX_CLASS_NAME_HPP_APP QX_REGISTER_COMPLEX_CLASS_NAME_HPP_EXPORT_DLL
#define QX_REGISTER_COMPLEX_CLASS_NAME_CPP_APP QX_REGISTER_COMPLEX_CLASS_NAME_CPP_EXPORT_DLL

namespace myspace {
QX_DLL_EXPORT class MyClass : public QObject {
   Q_OBJECT
   QX_REGISTER_FRIEND_CLASS(myspace::MyClass)
public:
   MyClass() : QObject()
   }
   virtual ~MyClass() {
   }
...
private:
   QString m_name;
};

typedef boost::shared_ptr<MyClass> MyClassPtr;
}
QX_REGISTER_COMPLEX_CLASS_NAME_HPP_DLL(myspace::MyClass, QObject, 0, myspace_MyClass)

Base source file
Code: Select all
QX_REGISTER_COMPLEX_CLASS_NAME_CPP_DLL(myspace::MyClass, myspace_MyCLass);
namespace qx {
template<>
void register_class(QxClass<myspace::MyClass> & t) {
   IxDataMember * pData = NULL;
   t.setName("entity");
   pData = t.data(&myspace::MyClass::m_name, "name", 1, true, false);
}
}

Just building my library for unit test give me following result
Code: Select all
/src/MyClass.o: In function `myspace::MyClass::MyClass()':
MyClass.cpp:(.text._ZN4sdbs3ifs9MyClassC1Ev[myspace::MyClass::MyClass()]+0x27): undefined reference to `vtable for myspace::MyClass'
./src/MyClass.o: In function `boost::serialization::extended_type_info_typeid<myspace::MyClass>::extended_type_info_typeid()':
MyClass.cpp:(.text._ZN5boost13serialization25extended_type_info_typeidIN4sdbs3ifs9MyClassEEC2Ev[boost::serialization::extended_type_info_typeid<myspace::MyClass>::extended_type_info_typeid()]+0x49): undefined reference to `typeinfo for myspace::MyClass'
./src/MyClass.o: In function `boost::serialization::extended_type_info_typeid<myspace::MyClass>::extended_type_info_typeid()':
MyClass.cpp:(.text._ZN5boost13serialization25extended_type_info_typeidIN4sdbs3ifs9MyClassEEC1Ev[boost::serialization::extended_type_info_typeid<myspace::MyClass>::extended_type_info_typeid()]+0x49): undefined reference to `typeinfo for myspace::MyClass'
./src/MyClass.o: In function `myspace::MyClass const* boost::serialization::smart_cast_impl::pointer<myspace::MyClass const*>::polymorphic::cast<QObject const>(QObject const*)':
MyClass.cpp:(.text._ZN5boost13serialization15smart_cast_impl7pointerIPKN4sdbs3ifs9MyClassEE11polymorphic4castIK7QObjectEES7_PT_[myspace::MyClass const* boost::serialization::smart_cast_impl::pointer<myspace::MyClass const*>::polymorphic::cast<QObject const>(QObject const*)]+0x23): undefined reference to `typeinfo for myspace::MyClass'
collect2: ld a retourné 1 code d'état d'exécution
make: *** [ifsbase] Erreur 1
ruddy32
 

Re: Class hierarchy

Postby ruddy32 » Sat Jan 08, 2011 8:15 am

The problem is caused by the QObject heritage.
ruddy32
 

Re: Class hierarchy

Postby QxOrm admin » Sat Jan 08, 2011 10:18 am

It is very strange : class 'CPerson' from the tutorial inherits from QObject and works without problem.

Verify your macro and take example from CPerson class in the directory <./test/dll1/> :
- QX_DLL_EXPORT
- QX_REGISTER_COMPLEX_CLASS_NAME_HPP_DLL
- QX_REGISTER_COMPLEX_CLASS_NAME_CPP_DLL

You can also send me at support@qxorm.com a minimal project to reproduce your linking problem.
QxOrm admin
 


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 16 guests

cron