Common ODB Runtime Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
tr1/lazy-pointer-traits.hxx
Go to the documentation of this file.
1 // file : odb/tr1/lazy-pointer-traits.hxx
2 // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
3 // license : GNU GPL v2; see accompanying LICENSE file
4 
5 #ifndef ODB_TR1_LAZY_POINTER_TRAITS_HXX
6 #define ODB_TR1_LAZY_POINTER_TRAITS_HXX
7 
8 #include <odb/pre.hxx>
9 
10 #include <odb/pointer-traits.hxx>
11 #include <odb/tr1/lazy-ptr.hxx>
12 
13 namespace odb
14 {
15  template <typename T>
16  class pointer_traits<tr1::lazy_shared_ptr<T> >
17  {
18  public:
19  static const pointer_kind kind = pk_shared;
20  static const bool lazy = true;
21 
22  typedef T element_type;
24  typedef std::tr1::shared_ptr<element_type> eager_pointer_type;
25 
26  static bool
28  {
29  return !p;
30  }
31 
32  template <class O /* = T */>
33  static typename object_traits<O>::id_type
35  {
36  return p.template object_id<O> ();
37  }
38  };
39 
40  template <typename T>
41  class pointer_traits<tr1::lazy_weak_ptr<T> >
42  {
43  public:
44  static const pointer_kind kind = pk_weak;
45  static const bool lazy = true;
46 
47  typedef T element_type;
50  typedef std::tr1::weak_ptr<element_type> eager_pointer_type;
51 
52  static strong_pointer_type
53  lock (const pointer_type& p)
54  {
55  return p.lock ();
56  }
57  };
58 }
59 
60 #include <odb/post.hxx>
61 
62 #endif // ODB_TR1_LAZY_POINTER_TRAITS_HXX
std::tr1::shared_ptr< element_type > eager_pointer_type
Definition: tr1/lazy-pointer-traits.hxx:24
Definition: pointer-traits.hxx:24
Definition: pointer-traits.hxx:23
Definition: tr1/lazy-ptr.hxx:32
tr1::lazy_shared_ptr< element_type > strong_pointer_type
Definition: tr1/lazy-pointer-traits.hxx:49
lazy_shared_ptr< T > lock() const
static bool null_ptr(const pointer_type &p)
Definition: tr1/lazy-pointer-traits.hxx:27
T element_type
Definition: tr1/lazy-pointer-traits.hxx:47
std::tr1::weak_ptr< element_type > eager_pointer_type
Definition: tr1/lazy-pointer-traits.hxx:50
Definition: pointer-traits.hxx:28
Definition: tr1/lazy-ptr.hxx:27
Definition: forward.hxx:123
tr1::lazy_weak_ptr< element_type > pointer_type
Definition: tr1/lazy-pointer-traits.hxx:48
tr1::lazy_shared_ptr< element_type > pointer_type
Definition: tr1/lazy-pointer-traits.hxx:23
static strong_pointer_type lock(const pointer_type &p)
Definition: tr1/lazy-pointer-traits.hxx:53
T element_type
Definition: tr1/lazy-pointer-traits.hxx:22
static object_traits< O >::id_type object_id(const pointer_type &p)
Definition: tr1/lazy-pointer-traits.hxx:34
pointer_kind
Definition: pointer-traits.hxx:19