CppELib 1.7.0
Loading...
Searching...
No Matches
TestDoubleVariableMemoryPoolFactory.h
Go to the documentation of this file.
1#ifndef TEST_DOUBLE_OS_WRAPPER_TEST_DOUBLE_VARIABLE_MEMORY_POOL_FACTORY_H_INCLUDED
2#define TEST_DOUBLE_OS_WRAPPER_TEST_DOUBLE_VARIABLE_MEMORY_POOL_FACTORY_H_INCLUDED
3
6#include <cstdlib>
7
8namespace TestDoubleOSWrapper {
9
11protected:
12 std::size_t m_memoryPoolSize;
14
15public:
21
22 void setCreateArgs(std::size_t memoryPoolSize, void* memoryPoolAddress)
23 {
24 m_memoryPoolSize = memoryPoolSize;
25 m_memoryPoolAddress = memoryPoolAddress;
26 }
27
29 {
30 }
31
32 virtual void* allocate(std::size_t size)
33 {
34 return std::malloc(size);
35 }
36
37 virtual void deallocate(void* p)
38 {
39 std::free(p);
40 }
41};
42
43template <typename T = TestDoubleVariableMemoryPool>
45public:
48
49 virtual OSWrapper::VariableMemoryPool* create(std::size_t memoryPoolSize, void* memoryPoolAddress)
50 {
51 T* obj = new T();
52 obj->setCreateArgs(memoryPoolSize, memoryPoolAddress);
53 return obj;
54 }
55
57 {
58 delete static_cast<T*>(p);
59 }
60
61private:
64};
65
66}
67
68#endif // TEST_DOUBLE_OS_WRAPPER_TEST_DOUBLE_VARIABLE_MEMORY_POOL_FACTORY_H_INCLUDED
Definition VariableMemoryPoolFactory.h:10
Abstract class that has functions of common RTOS's variable-size memory pool.
Definition VariableMemoryPool.h:21
Definition TestDoubleVariableMemoryPoolFactory.h:44
virtual void destroy(OSWrapper::VariableMemoryPool *p)
Definition TestDoubleVariableMemoryPoolFactory.h:56
TestDoubleVariableMemoryPoolFactory()
Definition TestDoubleVariableMemoryPoolFactory.h:46
virtual ~TestDoubleVariableMemoryPoolFactory()
Definition TestDoubleVariableMemoryPoolFactory.h:47
virtual OSWrapper::VariableMemoryPool * create(std::size_t memoryPoolSize, void *memoryPoolAddress)
Definition TestDoubleVariableMemoryPoolFactory.h:49
Definition TestDoubleVariableMemoryPoolFactory.h:10
std::size_t m_memoryPoolSize
Definition TestDoubleVariableMemoryPoolFactory.h:12
TestDoubleVariableMemoryPool()
Definition TestDoubleVariableMemoryPoolFactory.h:16
virtual ~TestDoubleVariableMemoryPool()
Definition TestDoubleVariableMemoryPoolFactory.h:28
void setCreateArgs(std::size_t memoryPoolSize, void *memoryPoolAddress)
Definition TestDoubleVariableMemoryPoolFactory.h:22
void * m_memoryPoolAddress
Definition TestDoubleVariableMemoryPoolFactory.h:13
virtual void * allocate(std::size_t size)
Allocate a memory from this VariableMemoryPool.
Definition TestDoubleVariableMemoryPoolFactory.h:32
virtual void deallocate(void *p)
Release the allocated memory.
Definition TestDoubleVariableMemoryPoolFactory.h:37
Implementation of OSWrapper for Test Double.
Definition TestDoubleEventFlagFactory.h:7