LCOV - code coverage report
Current view: top level - vset/memory/fsb/aspect - ad_begin.hpp (source / functions) Hit Total Coverage
Test: v-set-coverage.info Lines: 11 11 100.0 %
Date: 2019-09-12 Functions: 11 13 84.6 %

          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_VSET_MEMORY_FSB_ASPECT_AD_BEGIN_HPP
       8             : #define VSET_VSET_MEMORY_FSB_ASPECT_AD_BEGIN_HPP
       9             : 
      10             : #include <vset/buffer/tags.hpp>
      11             : #include <vset/memory/fsb/tags.hpp>
      12             : 
      13             : #include <fas/typemanip/type2type.hpp>
      14             : 
      15             : namespace vset { namespace memory{ namespace fsb{
      16             : 
      17          31 : struct ad_begin
      18             : {
      19             :   template<typename T, typename Pointer>
      20       30231 :   Pointer operator()(T& t, fas::type2type<Pointer> ) const
      21             :   {
      22       30231 :     return _<Pointer>(t);
      23             :   }
      24             :   
      25             : private:
      26             :   
      27             :   template<typename Pointer, typename T>
      28       30231 :   Pointer _(T& t) const
      29             :   {
      30             :     typedef ::vset::buffer::_size_      _buffer_size_;
      31             :     typedef ::vset::buffer::_data_type_ _buffer_data_type_;
      32             :     typedef ::vset::buffer::_data_      _buffer_data_;
      33             :     typedef Pointer pointer;
      34             : 
      35       30231 :     if ( t.get_aspect().template get< _buffer_size_ >()(t) == 0 )
      36             :     {
      37           2 :       return pointer( &t );
      38             :     }
      39             : 
      40             :     typedef typename T::aspect::template advice_cast<_chain_type_>::type chain_type;
      41             :     typedef typename T::aspect::template advice_cast<_value_type_>::type value_type;
      42             :     typedef typename T::aspect::template advice_cast<_buffer_data_type_>::type data_type;
      43             : 
      44       30229 :     data_type data = const_cast<data_type>( t.get_aspect().template get<_buffer_data_>()(t) );
      45             : 
      46       30229 :     chain_type* chn = reinterpret_cast<chain_type*>(data);
      47             : 
      48       30229 :     if ( value_type* value = chn->first_value() )
      49             :     {
      50       30228 :       return pointer( &t, t.get_aspect().template get<_offset_by_ptr_>()(t, value) );
      51             :       //return pointer( &t, static_cast<size_t>(reinterpret_cast<data_type>(value) - data) );
      52             :     }
      53             :     
      54           1 :     return pointer( &t );
      55             :   }
      56             : };
      57             : 
      58             : }}}
      59             : 
      60             : #endif

Generated by: LCOV version 1.10