[odb-users] Polymorphism through shared library

Boris Kolpackov boris at codesynthesis.com
Fri Nov 4 09:29:16 EDT 2016

Hi Arnaud,

Arnaud Kapp <arnaud.kapp at islog.com> writes:

> Sorry, this mail is getting a bit long, and is kinda messy.

Which is usually a good indication that even if you make it to work, it
will probably come to bite your later.

And the way you may be able to make it work is by taking the existing
building blocks and finding a way to combine them to achieve what you

Specifically, in ODB polymorphic inheritance is open-ended and the
base schema does not need to be changed in order to add a new derived
class. This is good for you.

Now you need to find a way to place derived classes into a separated
schema (--schema-name) with a separate version. I would start with
something like this:

// base.hxx

#  pragma db model version(...)

#pragma db object polymorphic
class base

// derived.hxx

#include "base.hxx"

#pragma db model version(...)

#pragma db object
class derived: public base

Then I would try to compile them like so and see what I get:

odb -s --schema-name base    base.hxx
odb -s --schema-name derived derived.hxx

One thing to keep in mind with this approach is that the derived schema
will always expect to see the latest version of the base scheme. This
might have implications.


More information about the odb-users mailing list