LCOV - code coverage report
Current view: top level - zerobuf - StaticSubAllocator.cpp (source / functions) Hit Total Coverage
Test: ZeroBuf Lines: 13 17 76.5 %
Date: 2018-01-09 16:38:26 Functions: 6 12 50.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2015, Human Brain Project
       3             :  *                     Stefan.Eilemann@epfl.ch
       4             :  *                     grigori.chevtchenko@epfl.ch
       5             :  */
       6             : 
       7             : #include "StaticSubAllocator.h"
       8             : #include <zerobuf/version.h>
       9             : 
      10             : #include <cstring>
      11             : 
      12             : namespace zerobuf
      13             : {
      14             : template <class A>
      15         111 : StaticSubAllocatorBase<A>::StaticSubAllocatorBase(A& parent,
      16             :                                                   const size_t offset,
      17             :                                                   const size_t size)
      18             :     : _parent(parent)
      19             :     , _offset(offset)
      20         111 :     , _size(size)
      21             : {
      22         111 : }
      23             : 
      24             : template <class A>
      25         222 : StaticSubAllocatorBase<A>::~StaticSubAllocatorBase()
      26             : {
      27         222 : }
      28             : 
      29             : template <class A>
      30         168 : uint8_t* StaticSubAllocatorBase<A>::getData()
      31             : {
      32         168 :     return _parent.getData() + _offset;
      33             : }
      34             : 
      35             : template <>
      36           0 : uint8_t* StaticSubAllocatorBase<const Allocator>::getData()
      37             : {
      38           0 :     throw std::runtime_error("Non-const data access on const data");
      39             : }
      40             : 
      41             : template <class A>
      42         243 : const uint8_t* StaticSubAllocatorBase<A>::getData() const
      43             : {
      44         243 :     return const_cast<const A&>(_parent).getData() + _offset;
      45             : }
      46             : 
      47             : template <class A>
      48          44 : void StaticSubAllocatorBase<A>::copyBuffer(const void* data, const size_t size)
      49             : {
      50          44 :     if (size != _size)
      51           0 :         throw std::runtime_error(
      52           0 :             "Can't copy buffer of different size into a static-sized member");
      53          44 :     ::memcpy(getData(), data, size);
      54          44 : }
      55             : 
      56             : template class StaticSubAllocatorBase<Allocator>;
      57             : template class StaticSubAllocatorBase<const Allocator>;
      58             : }

Generated by: LCOV version 1.11