ZeroBuf  0.4.0
Zero-copy, zero-serialize, zero-hassle protocol buffers
StaticSubAllocator.h
1 
2 /* Copyright (c) 2015, Human Brain Project
3  * Stefan.Eilemann@epfl.ch
4  */
5 
6 #ifndef ZEROBUF_STATICSUBALLOCATOR_H
7 #define ZEROBUF_STATICSUBALLOCATOR_H
8 
9 #include <zerobuf/api.h>
10 #include <zerobuf/Allocator.h> // base class
11 
12 namespace zerobuf
13 {
15 template< class A > class StaticSubAllocatorBase : public Allocator
16 {
17 public:
18  ZEROBUF_API StaticSubAllocatorBase( A& parent, size_t offset,
19  size_t size );
20  ZEROBUF_API ~StaticSubAllocatorBase();
21 
22  ZEROBUF_API uint8_t* getData() final;
23  ZEROBUF_API const uint8_t* getData() const final;
24  size_t getSize() const final { return _size; }
25  ZEROBUF_API void copyBuffer( const void* data, size_t size ) final;
26  bool isMutable() const final { return _parent.isMutable(); }
27 
28 private:
29  A& _parent;
30  const size_t _offset;
31  const size_t _size;
32 
33  StaticSubAllocatorBase( const StaticSubAllocatorBase< A >& ) = delete;
34  StaticSubAllocatorBase< A >& operator = (
35  const StaticSubAllocatorBase< A >& ) = delete;
36 };
37 
40 
41 }
42 
43 #endif
Defines export visibility macros for library ZeroBuf.
Zero-copy, zero-serialize, zero-hassle protocol buffers.
Definition: Allocator.h:12
A zerobuf child allocator which manages a static sub-struct.
Allocator base class and interface.
Definition: Allocator.h:20