[odb-users] Lazy pointer question

Javier Gutierrez javier.gutierrez at web.de
Mon Mar 12 12:33:40 EDT 2018


Hi there,

I don't have a lot of experience with ODB, but what I understand is that 
the lazy pointer always contains the ID of the object that is not yet 
loaded.

So if the ID column is called "id" then B->C->id would give the link.

Hope it helps, if not hope somebody else answers..

Best regards,

Javier


-------- Original Message --------
Subject: [odb-users] Lazy pointer question
From: Paul Stath <PStath at jmawireless.com>
To: odb-users at codesynthesis.com <odb-users at codesynthesis.com>
Date: 3/12/2018 4:18 PM
> Hi Boris,
>
> I have a question about using lazy pointers that I'm having trouble with.
> I have successfully used lazy pointers in a previous project for a different company, but no longer have access to that code, so I'm having to do it again.  (frown)
>
> I have an object B that has a lazy_weak_pointer<C> to object C.
> Object B is loaded due to an eager (std::shared_ptr<B>) pointer while object A is loaded.
> Relationship of objects A and B don't factor into this question, correct?
>
> How does one determine if object B is linked to object C without calling the lazy_weak_ptr<C>::load() method?
>
> In reading the documentation, section 6.4 describes contains the interface for the generic class lazy_pointer.
> Right above the loaded() method is a comment containing the following table:
>
> NULL                     loaded()
> true                       true                       NULL pointer to transient object
> false                       true                        valid pointer to persistent object
> true                        false                      unloaded pointer to persistent object
> false                       false                       valid pointer to transient object
>
> I also searched the odb-users mailing list archive and discovered the following topic:  https://www.codesynthesis.com/pipermail/odb-users/2016-June/003290.html
>
> Combining the manual and this mailing list entry, I have the following question:
>
> For a lazy_weak_ptr<C>:
> Does this mean the first column is the same as calling lazy_weak_ptr<C>.expired()?
> For a lazy_shared_ptr<C>:
> What does the first column indicate?
> Is that a simple bool check of the lazy_shared_ptr<C> instance?
> if (c_ptr && c_ptr.loaded())  { // valid pointer to persistent object }
>
> ---
> Paul Stath
> Senior Systems Software Engineer
> JMA Wireless
> pstath at jmawireless



More information about the odb-users mailing list