aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-05-21 19:22:51 -0400
committerBoris Kolpackov <boris@codesynthesis.com>2013-05-21 19:22:51 -0400
commitfb2519f6f9d79c7626a0281ad24925b4976cd81d (patch)
tree0363e3f37d2466b9411485e44638c76141deeacf
parent6c666b0dfa38cf1f6407817261a829645e86d855 (diff)
Add ability to get underlying eager pointer in weak pointers
-rw-r--r--odb/lazy-ptr.hxx25
-rw-r--r--odb/lazy-ptr.ixx35
-rw-r--r--odb/tr1/lazy-ptr.hxx10
-rw-r--r--odb/tr1/lazy-ptr.ixx14
4 files changed, 84 insertions, 0 deletions
diff --git a/odb/lazy-ptr.hxx b/odb/lazy-ptr.hxx
index d54cac0..e340d94 100644
--- a/odb/lazy-ptr.hxx
+++ b/odb/lazy-ptr.hxx
@@ -72,6 +72,11 @@ namespace odb
//
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.
+ //
+ T* get_eager () const;
+
template <class DB, class ID> lazy_ptr (DB&, const ID&);
template <class DB, class Y> lazy_ptr (DB&, Y*);
@@ -185,6 +190,11 @@ namespace odb
//
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.
+ //
+ std::auto_ptr<T>& get_eager () const;
+
template <class DB, class ID> lazy_auto_ptr (DB&, const ID&);
template <class DB> lazy_auto_ptr (DB&, T*);
template <class DB, class Y> lazy_auto_ptr (DB&, std::auto_ptr<Y>&);
@@ -305,6 +315,11 @@ namespace odb
//
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.
+ //
+ std::unique_ptr<T, D>& get_eager () const;
+
template <class DB, class ID> lazy_unique_ptr (DB&, const ID&);
template <class DB> lazy_unique_ptr (DB&, pointer);
template <class DB> lazy_unique_ptr (DB&, pointer, const deleter_type&);
@@ -464,6 +479,11 @@ namespace odb
//
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.
+ //
+ std::shared_ptr<T> get_eager () const;
+
template <class DB, class ID> lazy_shared_ptr (DB&, const ID&);
template <class DB, class Y> lazy_shared_ptr (DB&, Y*);
template <class DB, class Y, class D> lazy_shared_ptr (DB&, Y*, D);
@@ -593,6 +613,11 @@ namespace odb
//
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.
+ //
+ std::weak_ptr<T> get_eager () const;
+
template <class DB, class ID> lazy_weak_ptr (DB&, const ID&);
template <class DB, class Y> lazy_weak_ptr (DB&, const std::shared_ptr<Y>&);
template <class DB, class Y> lazy_weak_ptr (DB&, const std::weak_ptr<Y>&);
diff --git a/odb/lazy-ptr.ixx b/odb/lazy-ptr.ixx
index 724142a..da02528 100644
--- a/odb/lazy-ptr.ixx
+++ b/odb/lazy-ptr.ixx
@@ -137,6 +137,13 @@ namespace odb
}
template <class T>
+ inline T* lazy_ptr<T>::
+ get_eager () const
+ {
+ return p_;
+ }
+
+ template <class T>
template <class DB, class ID>
inline lazy_ptr<T>::
lazy_ptr (DB& db, const ID& id): p_ (0), i_ (db, id) {}
@@ -396,6 +403,13 @@ namespace odb
}
template <class T>
+ inline std::auto_ptr<T>& lazy_auto_ptr<T>::
+ get_eager () const
+ {
+ return p_;
+ }
+
+ template <class T>
template <class DB, class ID>
inline lazy_auto_ptr<T>::
lazy_auto_ptr (DB& db, const ID& id): i_ (db, id) {}
@@ -667,6 +681,13 @@ namespace odb
}
template <class T, class D>
+ inline std::unique_ptr<T, D>& lazy_unique_ptr<T, D>::
+ get_eager () const
+ {
+ return p_;
+ }
+
+ template <class T, class D>
template <class DB, class ID>
inline lazy_unique_ptr<T, D>::
lazy_unique_ptr (DB& db, const ID& id): i_ (db, id) {}
@@ -1150,6 +1171,13 @@ namespace odb
}
template <class T>
+ inline std::shared_ptr<T> lazy_shared_ptr<T>::
+ get_eager () const
+ {
+ return p_;
+ }
+
+ template <class T>
template <class DB, class ID>
inline lazy_shared_ptr<T>::
lazy_shared_ptr (DB& db, const ID& id): i_ (db, id) {}
@@ -1536,6 +1564,13 @@ namespace odb
}
template <class T>
+ inline std::weak_ptr<T> lazy_weak_ptr<T>::
+ get_eager () const
+ {
+ return p_;
+ }
+
+ template <class T>
template <class DB, class ID>
inline lazy_weak_ptr<T>::
lazy_weak_ptr (DB& db, const ID& id): i_ (db, id) {}
diff --git a/odb/tr1/lazy-ptr.hxx b/odb/tr1/lazy-ptr.hxx
index d877998..5e040cf 100644
--- a/odb/tr1/lazy-ptr.hxx
+++ b/odb/tr1/lazy-ptr.hxx
@@ -98,6 +98,11 @@ namespace odb
//
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.
+ //
+ std::tr1::shared_ptr<T> get_eager () const;
+
template <class DB, class ID> lazy_shared_ptr (DB&, const ID&);
template <class DB, class Y> lazy_shared_ptr (DB&, Y*);
template <class DB, class Y, class D> lazy_shared_ptr (DB&, Y*, D);
@@ -207,6 +212,11 @@ namespace odb
//
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.
+ //
+ std::tr1::weak_ptr<T> get_eager () const;
+
template <class DB, class ID> lazy_weak_ptr (DB&, const ID&);
template <class DB, class Y> lazy_weak_ptr (DB&, const std::tr1::shared_ptr<Y>&);
template <class DB, class Y> lazy_weak_ptr (DB&, const std::tr1::weak_ptr<Y>&);
diff --git a/odb/tr1/lazy-ptr.ixx b/odb/tr1/lazy-ptr.ixx
index b33a12d..59d72c0 100644
--- a/odb/tr1/lazy-ptr.ixx
+++ b/odb/tr1/lazy-ptr.ixx
@@ -207,6 +207,13 @@ namespace odb
}
template <class T>
+ inline std::tr1::shared_ptr<T> lazy_shared_ptr<T>::
+ get_eager () const
+ {
+ return p_;
+ }
+
+ template <class T>
template <class DB, class ID>
inline lazy_shared_ptr<T>::
lazy_shared_ptr (DB& db, const ID& id): i_ (db, id) {}
@@ -518,6 +525,13 @@ namespace odb
}
template <class T>
+ inline std::tr1::weak_ptr<T> lazy_weak_ptr<T>::
+ get_eager () const
+ {
+ return p_;
+ }
+
+ template <class T>
template <class DB, class ID>
inline lazy_weak_ptr<T>::
lazy_weak_ptr (DB& db, const ID& id): i_ (db, id) {}