Line data Source code
1 : //
2 : // Author: Vladimir Migashko <migashko@gmail.com>, (C) 2017
3 : //
4 : // Copyright: See COPYING file that comes with this distribution
5 : //
6 :
7 : #ifndef VSET_VSET_MEMORY_FSB_ASPECT_AD_POS2OFF_HPP
8 : #define VSET_VSET_MEMORY_FSB_ASPECT_AD_POS2OFF_HPP
9 :
10 : #include <vset/buffer/tags.hpp>
11 : #include <vset/memory/fsb/tags.hpp>
12 : #include <cstddef>
13 :
14 : namespace vset { namespace memory{ namespace fsb{
15 :
16 : struct ad_pos2off
17 : {
18 : template<typename T>
19 : size_t operator()(T&, size_t pos) const
20 : {
21 : typedef typename T::aspect::template advice_cast<_value_type_>::type value_type;
22 : typedef typename T::aspect::template advice_cast<_chunk_type_>::type chunk_type;
23 : typedef typename T::aspect::template advice_cast<_chain_type_>::type chain_type;
24 :
25 : size_t real_offset = chain_type::head_size();
26 : real_offset += chunk_type::head_size() + (pos / chunk_type::max_count()) * chunk_type::head_size();
27 : real_offset += sizeof(value_type)*pos;
28 : return real_offset;
29 : }
30 : };
31 :
32 31 : struct ad_pos2off_stub
33 : {
34 : template<typename T>
35 2900179 : size_t operator()(T&, size_t pos) const
36 : {
37 2900179 : return pos;
38 : }
39 : };
40 :
41 : }}}
42 :
43 : #endif
|