Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

pool.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                        pool.h  -  Multi-node hash table
00003                              -------------------
00004     begin                : Wed Feb 12 2003
00005     copyright            : (C) 2003 by Reality Rift Studios
00006     email                : mattias@realityrift.com
00007  ***************************************************************************
00008 
00009  The contents of this file are subject to the Mozilla Public License Version
00010  1.1 (the "License"); you may not use this file except in compliance with
00011  the License. You may obtain a copy of the License at 
00012  http://www.mozilla.org/MPL/
00013 
00014  Software distributed under the License is distributed on an "AS IS" basis,
00015  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  for the specific language governing rights and limitations under the
00017  License.
00018 
00019  The Original Code is the NeoEngine, pool.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2003
00023  Reality Rift Studios. All Rights Reserved.
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 //Macro for easy typing
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 

Generated on Wed Jan 21 14:21:07 2004 for NeoEngine by doxygen 1.3.5