[odb-users] Object Model based on Interfaces
Boris Kolpackov
boris at codesynthesis.com
Thu Jun 12 06:02:20 EDT 2014
Hi Christian,
Lichtenberger, Christian <christian.lichtenberger at etm.at> writes:
> #pragma db object polymorphic
> class Base
> {
> //some base functionality
> }
>
> class IDerived
> {
> //define pure virtual functions
> }
>
> #pragma db object
> class Derived : public Base, public IDerived
> {
> //implements virtual functions
> }
>
> How can I archive that following is possible:
>
> main()
> {
> QSharedPointer<odb::database> db;
> IDerived derived = new Derived;
> db->persist<IDerived>(derived);
> }
To persist via IDerived you would have to make it a persistent
object. But ODB does not support multiple inheritance. So the
only way is to simplify this somehow into a single inheritance
chain (e.g., derive Base from IDerived or the other way around).
Boris
More information about the odb-users
mailing list