00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __NEPOOL_H
00028 #define __NEPOOL_H
00029
00030
00037 #ifndef __NEED_VECTOR_STRING
00038 # define __NEED_VECTOR_STRING
00039 #endif
00040
00041 #include "base.h"
00042 #include "hash.h"
00043 #include "hashstring.h"
00044
00045 #include <vector>
00046
00047
00048 namespace NeoEngine
00049 {
00050
00051
00057 template < class PoolDataType > class PoolNode
00058 {
00059 public:
00060
00061 typedef std::vector< PoolDataType* > PoolDataVec;
00062
00064 HashString m_strKey;
00065
00067 PoolDataVec m_vpkData;
00068
00069
00074 inline PoolNode( const HashString &rstrKey, PoolDataType *pkData );
00075 };
00076
00077
00078
00086 template < class PoolDataType > class Pool
00087 {
00088 public:
00089
00090 typedef PoolNode< PoolDataType > PoolNodeType;
00091 typedef std::vector< PoolNodeType > PoolNodeVec;
00092 typedef std::vector< PoolNodeType* > PoolNodePtrVec;
00093 typedef std::vector< PoolDataType* > PoolDataVec;
00094
00098 enum POOLDEF
00099 {
00101 DEFAULTSIZE = 256
00102 };
00103
00104
00105 protected:
00106
00108 PoolNodeVec *m_pvkTable;
00109
00111 int m_iSize;
00112
00113
00120 inline PoolNodeType *LookupNode( const HashString &rstrKey, int iIndex = 0 );
00121
00122
00123 public:
00124
00128 Pool( int iSize = DEFAULTSIZE );
00129
00132 ~Pool();
00133
00134
00140 void Insert( const HashString &rstrKey, PoolDataType *pkData );
00141
00147 const PoolDataVec *Find( const HashString &rstrKey );
00148
00154 void Delete( const HashString &rstrKey, PoolDataType *pkData );
00155
00159 void GetAllNodes( PoolNodePtrVec *pvpkVector );
00160
00164 void GetAllNodeData( PoolDataVec *pvpkVector );
00165 };
00166
00167
00168
00169
00170 #if defined( WIN32 ) && defined( _MSC_VER ) && !defined( BUILD_STATIC )
00171
00172 #define PoolExport(classname) \
00173 class classname; \
00174 EXPIMP_TEMPLATE template class NEOENGINE_API Pool< classname >
00175
00176 #else
00177
00178 #define PoolExport(classname)
00179
00180 #endif
00181
00182
00183 #include "pool_inl.h"
00184
00185
00186 };
00187
00188
00189 #endif
00190