📄 icehandlemanager.h
字号:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Contains a handle manager.
* \file IceHandleManager.h
* \author Pierre Terdiman
* \date December, 12, 1999
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Include Guard
#ifndef __ICEHANDLEMANAGER_H__
#define __ICEHANDLEMANAGER_H__
typedef udword Handle;
class ICECORE_API HandleManager
{
public:
// Constructor / Destructor
HandleManager();
~HandleManager();
// Basic usage
Handle Add(void* object);
void Remove(Handle handle);
// Advanced usage
bool Remap(const udword* ranks);
// Physical data access
inline_ udword GetMaxNbObjects() const { return mMaxNbObjects; } //!< Returns max number of objects
inline_ udword GetNbObjects() const { return mCurrentNbObjects; } //!< Returns current number of objects
inline_ void** GetObjects() const { return mObjects; } //!< Gets the complete list of objects
void* GetObject(Handle handle) const; // Returns object according to handle.
//! High-speed access - same as GetObject without any checkings - handle with care.
inline_ void* PickObject(Handle handle) const { return mObjects[mOutToIn[uword(handle)]]; }
// Stats
udword GetUsedRam() const;
PREVENT_COPY(HandleManager)
private:
// Physical list
void** mObjects; //!< Physical list, with no holes but unsorted.
udword mCurrentNbObjects; //!< Current number of objects in the physical list.
udword mMaxNbObjects; //!< Maximum possible number of objects in the physical list.
// Cross-references
uword* mOutToIn; //!< Maps virtual indices (handles) to real ones.
uword* mInToOut; //!< Maps real indices to virtual ones (handles).
uword* mStamps;
// Recycled locations
udword mNbFreeIndices; //!< Current number of free indices
// Internal methods
bool SetupLists(void** objects=null, uword* oti=null, uword* ito=null, uword* stamps=null);
};
#endif //__ICEHANDLEMANAGER_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -