ZeroBuf  0.5.0
Zero-copy, zero-serialize, zero-hassle protocol buffers
DynamicSubAllocator.h
1 
2 /* Copyright (c) 2015, Human Brain Project
3  * Stefan.Eilemann@epfl.ch
4  */
5 
6 #ifndef ZEROBUF_DYNAMICSUBALLOCATOR_H
7 #define ZEROBUF_DYNAMICSUBALLOCATOR_H
8 
9 #include <zerobuf/Allocator.h> // base class
10 #include <zerobuf/api.h>
11 
12 namespace zerobuf
13 {
18 template <class A>
20 {
21 public:
22  ZEROBUF_API DynamicSubAllocatorBase(A& parent, size_t headerIndex,
23  size_t elementIndex, size_t size);
24  ZEROBUF_API ~DynamicSubAllocatorBase();
25 
26  ZEROBUF_API uint8_t* getData() final;
27  ZEROBUF_API const uint8_t* getData() const final;
28  size_t getSize() const final { return _size; }
29  ZEROBUF_API void copyBuffer(const void* data, size_t size) final;
30  bool isMutable() const final { return _parent.isMutable(); }
31 private:
32  A& _parent;
33  const size_t _header;
34  const size_t _element;
35  const size_t _size;
36 
37  DynamicSubAllocatorBase(const DynamicSubAllocatorBase<A>&) = delete;
39  delete;
40 };
41 
44 }
45 
46 #endif
Defines export visibility macros for library ZeroBuf.
Zero-copy, zero-serialize, zero-hassle protocol buffers.
Definition: Allocator.h:12
Allocator base class and interface.
Definition: Allocator.h:20
A zerobuf child allocator which manages a dynamic allocation of statically-sized members.