[Qt-interest] using QObject's for object-relational mapping system

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Wed Jan 14 15:33:09 CET 2009


Dmitry Teslenko wrote on Wednesday, January 14, 2009 12:29 PM:

> ... How could this solution be
> resource-intense and what magnitudes of QObjects could I operate this
> way?

Hard to say, without knowing the actual implementation: first I would study

  http://www.parashift.com/c++-faq-lite/serialization.html#faq-36.7

to get an idea about the caveats of such a serialisation framework (and what it should be able to cope with, e.g dependency cycles).

For objects which are already derived from QObject and have Qt meta Information (QMetaObject - Q_OBJECT macro present) there is probably not much more overhead, other the one which is needed for solving issues discussed above.

The interesting thing comes in here: how do you cope with objects which are NOT derived from QObject or don't have meta information (no Q_OBJECT macro in their class definition)?


class NotAQObjectDerived {
  ...
};

class DoesNotHaveQtMetaInformation : public QObject {
  // no Q_OBJECT macro here!
  ...
};

class SerialiseMe : public QObject {
  Q_OBJECT
public:
  ...
private:
  // how to de-/serialise those?
  NotAQObjectDerivedClass *m_notAQObject;
  DoesNotHaveQtMetaInformation  *m_noMetaInfo;
};

A simple solution could be to "force" all your objects to really derive from QObject and have a valid QMetaObject, so the additional overhead would be defined by the number of non-QObject classes you had before - if this solution is actually practicable (you would limit your serialisation framework to QObject based classes which would not be allowed contain any references to non-QObject classes - but again, that depends on how much your implementation would rely on the presence of QMetaObject).

Base line: I wouldn't worry so much about the needed resources (note: in the Java world where I am currently working in every object is derived from 'Object' and has "meta info", so no worries here ;) but on the practicability of relying on the presence of QMetaObject information!


Off course such a framework would be very useful if it worked :)

Good luck, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22




More information about the Qt-interest-old mailing list