ZeroBuf  0.5.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/Allocator.h> // base class
10 #include <zerobuf/api.h>
11 
12 namespace zerobuf
13 {
15 template <class A>
17 {
18 public:
19  ZEROBUF_API StaticSubAllocatorBase(A& parent, size_t offset, 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 private:
28  A& _parent;
29  const size_t _offset;
30  const size_t _size;
31 
32  StaticSubAllocatorBase(const StaticSubAllocatorBase<A>&) = delete;
34  delete;
35 };
36 
39 }
40 
41 #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