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_OFF2POS_HPP
8 : #define VSET_VSET_MEMORY_FSB_ASPECT_AD_OFF2POS_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_off2pos
17 : {
18 : template<typename T>
19 : size_t operator()(T&, size_t offset) 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 : offset -= chain_type::head_size();
25 : offset -= ( offset/chunk_type::size() ) * chunk_type::head_size();
26 : offset -= chunk_type::head_size();
27 : return offset/sizeof(value_type);
28 : }
29 : };
30 :
31 31 : struct ad_off2pos_stub
32 : {
33 : template<typename T>
34 166254 : size_t operator()(T&, size_t offset) const
35 : {
36 166254 : return offset;
37 : }
38 : };
39 :
40 :
41 : }}}
42 :
43 : #endif
|