diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-05-21 19:22:51 -0400 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-05-21 19:22:51 -0400 |
commit | 9608495c8c9a4ee3900cf98830dc7b497c1edd10 (patch) | |
tree | 320556960db14204d7c147da0ffadcb71447f0cc | |
parent | e7e51cb35cf143153521f77173185fc37c738aff (diff) |
Add ability to get underlying eager pointer in weak pointers
-rw-r--r-- | odb/qt/smart-ptr/lazy-ptr.hxx | 12 | ||||
-rw-r--r-- | odb/qt/smart-ptr/lazy-ptr.ixx | 14 |
2 files changed, 26 insertions, 0 deletions
diff --git a/odb/qt/smart-ptr/lazy-ptr.hxx b/odb/qt/smart-ptr/lazy-ptr.hxx index 71c606c..d7a077d 100644 --- a/odb/qt/smart-ptr/lazy-ptr.hxx +++ b/odb/qt/smart-ptr/lazy-ptr.hxx @@ -153,6 +153,12 @@ public: // void unload () const; + // Get the underlying eager pointer. If this is an unloaded pointer + // to a persistent object, then the returned pointer will be NULL. + // + QSharedPointer<T> + getEager () const; + template <class DB, class ID> QLazySharedPointer (DB&, const ID&); @@ -328,6 +334,12 @@ public: void unload () const; + // Get the underlying eager pointer. If this is an unloaded pointer + // to a persistent object, then the returned pointer will be NULL. + // + QWeakPointer<T> + getEager () const; + template <class DB, class ID> QLazyWeakPointer (DB&, const ID&); diff --git a/odb/qt/smart-ptr/lazy-ptr.ixx b/odb/qt/smart-ptr/lazy-ptr.ixx index 091d729..a78e52c 100644 --- a/odb/qt/smart-ptr/lazy-ptr.ixx +++ b/odb/qt/smart-ptr/lazy-ptr.ixx @@ -221,6 +221,13 @@ unload () const } template <class T> +inline QSharedPointer<T> QLazySharedPointer<T>:: +getEager () const +{ + return p_; +} + +template <class T> template <class DB, class ID> inline QLazySharedPointer<T>:: QLazySharedPointer (DB& db, const ID& id): i_ (db, id) {} @@ -480,6 +487,13 @@ unload () const } template <class T> +inline QWeakPointer<T> QLazyWeakPointer<T>:: +getEager () const +{ + return p_; +} + +template <class T> template <class DB, class ID> inline QLazyWeakPointer<T>:: QLazyWeakPointer (DB& db, const ID& id): i_ (db, id) {} |