True Axis Physics SDK 1.2.0.1 Beta Documentation
www.trueaxis.com

SimplePool.h

00001 //---------------------------------------------------------------------------------
00002 // File Name: SimplePool.h
00003 // Description:
00004 //
00005 // Copyright (C) 2004 - 2006 True Axis Pty Ltd, Australia. 
00006 // All Rights Reserved.
00007 //
00008 // History:
00009 //      Created File.
00010 //---------------------------------------------------------------------------------
00011 
00012 #ifndef TA_SIMPLEPOOL_H
00013 #define TA_SIMPLEPOOL_H
00014 
00015 namespace TA
00016 {
00017 
00018 // todo: A debug version would be nice.
00019 template <class Type>
00020 class SimplePool
00021 {
00022 public:
00023     SimplePool();
00024     ~SimplePool();
00025 
00026     void Initialise(int nSize);
00027     void Finalise();
00028 
00029     Type* Alloc();
00030     void Free(Type* pData);
00031 
00032 private:
00033     struct Item
00034     {
00035         Type data;
00036     };
00037     
00038     Item* m_pData;
00039     int m_nSize;
00040     int m_nFreeCount;
00041     Item* m_pFreeList;
00042 
00043     Item*& ItemToNextPtr(Item& item) { return (Item*&)item; }
00044 };
00045 
00046 }
00047 
00048 #include "SimplePool.inl"
00049 
00050 #endif // TA_SIMPLEPOOL_H


© Copyright 2004-2006 TRUE AXIS PTY LTD Australia. All rights reserved.