ZeroBuf  0.4.0
Zero-copy, zero-serialize, zero-hassle protocol buffers
NonMovingBaseAllocator.h
1 
2 /* Copyright (c) 2015-2016, Human Brain Project
3  * Stefan.Eilemann@epfl.ch
4  * grigori.chevtchenko@epfl.ch
5  */
6 
7 #ifndef ZEROBUF_NONMOVINGBASEALLOCATOR_H
8 #define ZEROBUF_NONMOVINGBASEALLOCATOR_H
9 
10 #include <zerobuf/api.h>
11 #include <zerobuf/Allocator.h> // base class
12 
13 namespace zerobuf
14 {
17 {
18 public:
19  ZEROBUF_API NonMovingBaseAllocator( size_t staticSize, size_t numDynamic );
20 
21  ZEROBUF_API virtual ~NonMovingBaseAllocator();
22 
23  ZEROBUF_API uint8_t* updateAllocation( size_t index, bool copy,
24  size_t size ) final;
25  ZEROBUF_API void compact( float threshold ) final;
26 
27 protected:
28  virtual void _resize( size_t newSize ) = 0;
29 
30 private:
31  NonMovingBaseAllocator( const NonMovingBaseAllocator& ) = delete;
32  NonMovingBaseAllocator& operator = (
33  const NonMovingBaseAllocator& ) = delete;
34 
35  size_t _staticSize;
36  size_t _numDynamic;
37 
38  uint8_t* _moveAllocation( size_t index, bool copy, size_t newOffset,
39  size_t newSize );
40 };
41 }
42 #endif
uint8_t * updateAllocation(size_t index, bool copy, size_t size) final
Update allocation of the dynamic elem at index to have newSize bytes.
Allocator base class which does not move existing fields.
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