// file : odb/tr1/lazy-ptr.txx // author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file namespace odb { namespace tr1 { // // lazy_shared_ptr // template template bool lazy_shared_ptr:: equal (const lazy_shared_ptr& r) const { if (loaded () && r.loaded ()) return p_ == r.p_; // If one of the object is not loaded, then we compare databases and // object ids. Note that NULL pointers cannot have non-NULL databases // and if both of them are NULL, we wouldn't have gotten here. // typedef typename object_traits::object_type object_type1; typedef typename object_traits::object_type object_type2; return i_.database () == r.i_.database () && object_id () == r.object_id (); } // // lazy_weak_ptr // template lazy_shared_ptr lazy_weak_ptr:: lock () const { std::tr1::shared_ptr sp (p_.lock ()); if (sp) { if (database_type* db = i_.database ()) return lazy_shared_ptr (*db, sp); else return lazy_shared_ptr (sp); } else { if (i_) return lazy_shared_ptr (*i_.database (), i_.object_id ()); else return lazy_shared_ptr (); } } } }