Line data Source code
1 : //
2 : // Author: Vladimir Migashko <migashko@gmail.com>, (C) 2012
3 : //
4 : // Copyright: See COPYING file that comes with this distribution
5 : //
6 :
7 : #ifndef VSET_MEMORY_MANAGER_BASE_HPP
8 : #define VSET_MEMORY_MANAGER_BASE_HPP
9 :
10 : #include <cstddef>
11 :
12 : #include <fas/system/nullptr.hpp>
13 : #include <vset/memory/tags.hpp>
14 : #include <fas/typemanip/type2type.hpp>
15 : #include <fas/aop.hpp>
16 : #include <iostream>
17 :
18 : #include <vset/memory/aspect_maker.hpp>
19 :
20 : namespace vset { namespace memory{
21 :
22 : template<typename A >
23 14 : class manager_base
24 : : public fas::aspect_class<A>
25 : {
26 : typedef fas::aspect_class<A> super;
27 : typedef manager_base<A> self;
28 :
29 : protected:
30 :
31 : typedef typename aspect_maker<self>::value_type value_type;
32 : typedef typename aspect_maker<self>::buffer_type buffer_type;
33 : typedef typename aspect_maker<self>::pointer pointer;
34 : typedef typename aspect_maker<self>::const_pointer const_pointer;
35 : typedef typename aspect_maker<self>::difference_type difference_type;
36 :
37 : typedef size_t size_type;
38 :
39 : template<typename T>
40 30220 : pointer _begin(T& t)
41 : {
42 30220 : return t.get_aspect().template get<_begin_>()(t, fas::type2type<pointer>() );
43 : }
44 :
45 : template<typename T>
46 9 : const_pointer _begin(T& t) const
47 : {
48 9 : return t.get_aspect().template get<_begin_>()(t, fas::type2type<const_pointer>() );
49 : }
50 :
51 : template<typename T>
52 20216 : pointer _end(T& t)
53 : {
54 20216 : return t.get_aspect().template get<_end_>()(t, fas::type2type<pointer>() );
55 : }
56 :
57 : template<typename T>
58 414 : const_pointer _end(T& t) const
59 : {
60 414 : return t.get_aspect().template get<_end_>()(t, fas::type2type<const_pointer>() );
61 : }
62 :
63 : template<typename T>
64 10797 : pointer _allocate(T& t, size_t num, void * hint = fas_nullptr)
65 : {
66 10797 : return t.get_aspect().template get<_allocate_>()(t, fas::type2type<pointer>(), num, hint );
67 : }
68 :
69 : template<typename T>
70 10006 : void _deallocate(T& t, pointer ptr, size_type num)
71 : {
72 10006 : return t.get_aspect().template get<_deallocate_>()(t, ptr, num );
73 : }
74 :
75 : template<typename T>
76 206 : size_type _count(T& t) const
77 : {
78 206 : return t.get_aspect().template get<_count_>()(t);
79 : }
80 :
81 : template<typename T>
82 3 : size_type _capacity(T& t) const
83 : {
84 3 : return t.get_aspect().template get<_capacity_>()(t);
85 : }
86 :
87 : template<typename T>
88 17 : buffer_type _buffer(T& t)
89 : {
90 17 : return buffer_type(&t);
91 : }
92 :
93 : template<typename T>
94 : const buffer_type _buffer(T& t) const
95 : {
96 : return buffer_type(&t);
97 : }
98 :
99 : };
100 :
101 : }}
102 :
103 : #endif
|