ZeroBuf  0.4.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/api.h>
10 #include <zerobuf/Allocator.h> // base class
11 
12 namespace zerobuf
13 {
18 template< class A > class DynamicSubAllocatorBase : public Allocator
19 {
20 public:
21  ZEROBUF_API DynamicSubAllocatorBase( A& parent, size_t headerIndex,
22  size_t elementIndex, size_t size );
23  ZEROBUF_API ~DynamicSubAllocatorBase();
24 
25  ZEROBUF_API uint8_t* getData() final;
26  ZEROBUF_API const uint8_t* getData() const final;
27  size_t getSize() const final { return _size; }
28  ZEROBUF_API void copyBuffer( const void* data, size_t size ) final;
29  bool isMutable() const final { return _parent.isMutable(); }
30 
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;
38  DynamicSubAllocatorBase< A >& operator = (
39  const DynamicSubAllocatorBase< A >& ) = delete;
40 };
41 
44 
45 }
46 
47 #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.