blob: c3055c906fd363b04e83f4a4e06f6f1a068c8fed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// file : odb/lazy-ptr-impl.txx
// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/database.hxx>
namespace odb
{
//
// lazy_ptr_base
//
template <typename T>
void lazy_ptr_base::
free (void* p)
{
delete static_cast<T*> (p);
}
template <typename T>
void* lazy_ptr_base::
copy (const void* p)
{
return new T (*static_cast<const T*> (p));
}
//
// lazy_ptr_impl
//
template <typename T>
template <typename O>
inline typename object_traits<O>::pointer_type lazy_ptr_impl<T>::
load (bool reset)
{
typedef typename object_traits<T>::id_type id_type;
typedef typename object_traits<T>::pointer_type pointer_type;
const id_type& id (*static_cast<const id_type*> (id_));
pointer_type p (db_->load<T> (id));
if (reset)
reset_id ();
// If you get a compile error pointing here, then you most likely
// used a wrong type as a template argument in the load() call.
//
return p;
}
}
|