|
6 | 6 |
|
7 | 7 | namespace RTE {
|
8 | 8 |
|
| 9 | + typedef std::function<void*()> MemoryAllocate; //!< Convenient name definition for the memory allocation callback function. |
| 10 | + typedef std::function<void(void*)> MemoryDeallocate; //!< Convenient name definition for the memory deallocation callback function. |
9 | 11 |
|
10 | 12 | #pragma region Global Macro Definitions
|
11 | 13 | #define ABSTRACTCLASSINFO(TYPE, PARENT) \
|
@@ -92,7 +94,7 @@ namespace RTE {
|
92 | 94 | /// <param name="fpDeallocFunc">Function pointer to the raw deallocation function of memory. If the represented Entity subclass isn't concrete, pass in 0.</param>
|
93 | 95 | /// <param name="fpNewFunc">Function pointer to the new instance factory. If the represented Entity subclass isn't concrete, pass in 0.</param>
|
94 | 96 | /// <param name="allocBlockCount">The number of new instances to fill the pre-allocated pool with when it runs out.</param>
|
95 |
| - ClassInfo(const std::string &name, ClassInfo *pParentInfo = 0, void * (*fpAllocFunc)() = 0, void(*fpDeallocFunc)(void *) = 0, Entity * (*fpNewFunc)() = 0, int allocBlockCount = 10); |
| 97 | + ClassInfo(const std::string &name, ClassInfo *pParentInfo = 0, MemoryAllocate fpAllocFunc = 0, MemoryDeallocate fpDeallocFunc = 0, Entity * (*fpNewFunc)() = 0, int allocBlockCount = 10); |
96 | 98 | #pragma endregion
|
97 | 99 |
|
98 | 100 | #pragma region Getters
|
@@ -182,9 +184,10 @@ namespace RTE {
|
182 | 184 | int m_PoolAllocBlockCount; //!< The number of instances to fill up the pool of this type with each time it runs dry.
|
183 | 185 | int m_InstancesInUse; //!< The number of allocated instances passed out from the pool.
|
184 | 186 |
|
185 |
| - void *(*m_fpAllocate)(); //!< Raw memory allocation for the size of the type this ClassInfo describes. |
186 |
| - void(*m_fpDeallocate)(void *); //!< Raw memory deallocation for the size of the type this ClassInfo describes. |
| 187 | + MemoryAllocate m_fpAllocate; //!< Raw memory allocation for the size of the type this ClassInfo describes. |
| 188 | + MemoryDeallocate m_fpDeallocate; //!< Raw memory deallocation for the size of the type this ClassInfo describes. |
187 | 189 |
|
| 190 | + // TODO: figure out why this doesn't want to work when defined as std::function. |
188 | 191 | Entity *(*m_fpNewInstance)(); //!< Returns an actual new instance of the type that this describes.
|
189 | 192 |
|
190 | 193 | // Forbidding copying
|
|
0 commit comments