[odb-users] Polymorphism through shared library
boris at codesynthesis.com
Thu Nov 10 03:58:13 EST 2016
Arnaud Kapp <arnaud.kapp at islog.com> writes:
> Does the database support code for each class register itself, saying
> "Hey I can handle object with typeid "MyNamespace::myType" and, from
> this, ODB is able to instantiate the correct type?
Yes, that's pretty much how it works.
> I am not yet sure it makes sense, but would it be possible to tell ODB to
> fallback to instantiating an other type in case the type is not available?
> If DerivedType cannot be instantiated, fall-back to instantiating ParentType.
> I have a use case for this, but on the other hand I wonder if I'm not
> opening a can of worm that should stay closed:
Yes, you most likely are. This would be similar to object slicing in
C++. For example you could modify some data in the base that is
inconsistent with the "cut off" part.
More information about the odb-users