[odb-users] Polymorphism and lazy/weak pointers
gerasch at informatik.uni-tuebingen.de
Mon Jan 30 04:00:33 EST 2012
in our project we use ODB for serializing polymorphic objects. Since
polymorphism isn't yet supported by odb, we use the callback
functionality and encode the correct types in the object ids.
Currently, we're using boost::shared_ptr for relations, which works
quite well, but we would like to introduce lazy (weak) loading.
Do you know if polymorphism works together with lazy loading? In the
callback method (below an example from our code) we could create lazy
pointers instead of loading instances, but I have no idea if this would
result in the correct types or if odb is able to locate the
(polymorphic) objects in the correct database table after casting the
void UniPAX::Pathway::init (odb::callback_event e, odb::database& db)
if (e == odb::callback_event::post_load)
// load the object pointer
std::vector<unsigned long long>::iterator it;
for (it = id_pathwayComponent.begin(); it !=
Second, is there a possibility to change the caching of objects in a
session from shared to weak without changing the pointer types of the
objects? We need to implement an object cache which will deallocate
unused objects again automatically, but we could live with shared_ptr in
our data model, because it has no bidirectional links.
Thanks for your help,
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 435 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20120130/7b466e0f/gerasch.vcf
More information about the odb-users