📄 oasispool.h
字号:
/******************************************************************************
* This source file is part of Bad Camel Gaming
* Copyright (C) 2003 Zephie Greyvenstein
* See Readme.html for acknowledgements
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*****************************************************************************/
/******************************************************************************
* FILENAME : oasisPool.h
* DESCRIPTION : Pools objects
* AUTHOR : Zephie Greyvenstein
*****************************************************************************/
/// Avoid double inclusion
#ifndef __POOL_H__
#define __POOL_H__
/// Include common stuff
#include "oasisCommon.h"
namespace Oasis {
/** Pools objects
@remarks
Classes of this type can pool poolable objects for easier management
of objects which get created and destroyed a lot during run time
*/
class _oasisExport pool {
public:
/// Constructor
pool( const string &name );
/// Destructor
virtual ~pool( );
/// Clear and reset the pool
void clearPool( void );
/// Get the pool's name
const string &getPoolName( void ) const;
/// Set pool size
bool setPoolSize( uint16 newSize );
/// Get pool size
const uint16 getPoolSize( void ) const;
/// Get the next unique name for this pool
const string &getNextUniqueName( void );
/// Reset the unique naming counters
void resetUniqueNames( void );
protected:
/// The pool's name
string poolName;
/// The unique naming identifier
uint32 namingCounter;
/// Deque of poolables
typedef std::deque< poolable* > poolableDeque;
/// Map of poolables
typedef std::map< string, poolable* > poolableMap;
/// Vector of poolables
typedef std::vector< poolable* > poolableVector;
/// The free poolable objects
poolableDeque freePool;
/// Poolables in use
poolableMap usedPool;
/// The whole object pool
poolableVector allPool;
/// Get the next unused poolable, possibly increasing the pool
poolable *_getFreePoolable( const string &poolableName );
/// Retrieves a used poolable by name
poolable *_getUsedPoolable( const string &poolableName );
/// Return a poolable to the pool
void _consumePoolable( poolable *oldPoolable );
/// Return a poolable to the pool
void _consumePoolable( const string &poolableName );
/// Creates a new poolable object
virtual poolable *_createPoolable( void ) = 0;
/// Destroy all objects for real
void _destroyAll( void );
};
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -