From cd09ab74e179fd4c42ad226fd5cc609485a8df01 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 22 Nov 2010 12:01:11 +0200 Subject: Add pointer kind and const_pointer to pointer traits --- odb/pointer-traits.hxx | 14 ++++++++++++++ odb/tr1-pointer-traits.hxx | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/odb/pointer-traits.hxx b/odb/pointer-traits.hxx index 34ec7cd..cd25820 100644 --- a/odb/pointer-traits.hxx +++ b/odb/pointer-traits.hxx @@ -14,6 +14,14 @@ namespace odb { + enum pointer_kind + { + pk_naked, // Naked or equivalent (i.e., unmanaged). + pk_unique, // Smart pointer that doesn't support sharing. + pk_shared, // Smart pointer that support sharing. + pk_weak // Weak counterpart for shared pointer. + }; + template class pointer_traits; @@ -67,8 +75,11 @@ namespace odb class pointer_traits { public: + static pointer_kind const kind = pk_naked; + typedef T element_type; typedef T* pointer_type; + typedef const T* const_pointer_type; typedef naked_ptr_guard guard_type; // Return naked pointer to the pointed-to element, including NULL. @@ -124,8 +135,11 @@ namespace odb class pointer_traits< std::auto_ptr > { public: + static pointer_kind const kind = pk_unique; + typedef T element_type; typedef std::auto_ptr pointer_type; + typedef std::auto_ptr const_pointer_type; typedef smart_ptr_guard guard_type; static element_type* diff --git a/odb/tr1-pointer-traits.hxx b/odb/tr1-pointer-traits.hxx index edb5ce8..121a564 100644 --- a/odb/tr1-pointer-traits.hxx +++ b/odb/tr1-pointer-traits.hxx @@ -21,8 +21,11 @@ namespace odb class pointer_traits< std::tr1::shared_ptr > { public: + static pointer_kind const kind = pk_shared; + typedef T element_type; typedef std::tr1::shared_ptr pointer_type; + typedef std::tr1::shared_ptr const_pointer_type; typedef smart_ptr_guard guard_type; static element_type* @@ -63,9 +66,13 @@ namespace odb class pointer_traits< std::tr1::weak_ptr > { public: + static pointer_kind const kind = pk_weak; + typedef T element_type; typedef std::tr1::weak_ptr pointer_type; + typedef std::tr1::weak_ptr const_pointer_type; typedef std::tr1::shared_ptr strong_pointer_type; + typedef std::tr1::shared_ptr strong_const_pointer_type; }; } -- cgit v1.1