From ec355c48c49074bebeb597f6e5dcedfeb9d52fae Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 9 Dec 2010 10:36:15 +0200 Subject: Add lazy pointer support Built-in support is provided for raw, auto, and tr1 shared/weak pointers. New test: common/lazy-ptr. --- odb/lazy-ptr.txx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 odb/lazy-ptr.txx (limited to 'odb/lazy-ptr.txx') diff --git a/odb/lazy-ptr.txx b/odb/lazy-ptr.txx new file mode 100644 index 0000000..c016588 --- /dev/null +++ b/odb/lazy-ptr.txx @@ -0,0 +1,30 @@ +// file : odb/lazy-ptr.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + // + // lazy_ptr + // + + template + template + bool lazy_ptr:: + equal (const lazy_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 (); + } +} -- cgit v1.1