LCOV - code coverage report
Current view: top level - zerobuf - ConstAllocator.h (source / functions) Hit Total Coverage
Test: ZeroBuf Lines: 11 11 100.0 %
Date: 2018-01-09 16:38:26 Functions: 7 7 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2015-2016, Human Brain Project
       3             :  *                          Daniel.Nachbaur@epfl.ch
       4             :  */
       5             : 
       6             : #ifndef ZEROBUF_CONSTALLOCATOR_H
       7             : #define ZEROBUF_CONSTALLOCATOR_H
       8             : 
       9             : #include <zerobuf/Allocator.h> // base class
      10             : #include <zerobuf/api.h>
      11             : 
      12             : namespace zerobuf
      13             : {
      14             : /** A zerobuf root allocator which gives read-only access to its data. */
      15             : class ConstAllocator : public Allocator
      16             : {
      17             : public:
      18             :     ZEROBUF_API ConstAllocator(const uint8_t* data, size_t size);
      19             : 
      20             :     ZEROBUF_API ~ConstAllocator();
      21             : 
      22         181 :     const uint8_t* getData() const final { return _data; }
      23          37 :     size_t getSize() const final { return _size; }
      24           4 :     bool isMutable() const final { return false; }
      25             : private:
      26             :     ConstAllocator(const ConstAllocator&) = delete;
      27             :     ConstAllocator& operator=(const ConstAllocator&) = delete;
      28             : 
      29           1 :     uint8_t* getData() final
      30             :     {
      31           1 :         throw std::runtime_error("No mutable getData() for ConstAllocator");
      32             :     }
      33           1 :     void copyBuffer(const void*, size_t) final
      34             :     {
      35           1 :         throw std::runtime_error("No copyBuffer for ConstAllocator");
      36             :     }
      37           1 :     uint8_t* updateAllocation(size_t, bool, size_t) final
      38             :     {
      39           1 :         throw std::runtime_error("No updateAllocation for ConstAllocator");
      40             :     }
      41           1 :     void compact(float) final
      42             :     {
      43           1 :         throw std::runtime_error("No compact for ConstAllocator");
      44             :     }
      45             : 
      46             :     const uint8_t* _data;
      47             :     const size_t _size;
      48             : };
      49             : }
      50             : 
      51             : #endif

Generated by: LCOV version 1.11