亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? resarray.cpp

?? 這個(gè)是我第一次完成的一個(gè)簡單的3D ALIEN SHOOTING GAME的RESOURCE MANAGER部分,大家可以看看,然后提點(diǎn)意見~THX
?? CPP
字號(hào):
// ResArray.cpp
//

// Author:			Lea Hayes
// Date Created:	10/03/2006
// Date Modified:	24/03/2006

#include "Common.h"
#include "ResArray.h"

using namespace Resources;


// ResourceArray - Construction and destruction.

ResourceArray::ResourceArray()
: m_pBegin(NULL)
, m_pEnd(NULL)
, m_pLast(NULL)
, m_nSize(NULL)
, m_bAutoFree(true)
{
	// Automatically update resource array structure where necessary.
	QueryUpdate();
}

ResourceArray::~ResourceArray()
{
	// Free resources from memory.
	Destroy();
}


// Function Name:	Destroy
//
// Author:			Lea Hayes
// Date Created:	10/03/2006
// Date Modified:	10/03/2006
//
// Description:		Free all resources from memory and clear array.
//
void ResourceArray::Destroy()
{
	// Iterate through each resource and free from memory.
	iterator itCur = Begin();
	LPLISTNODE pCurNode = NULL;

	while(itCur.IsValid())
	{
		// Preserve pointer to current element.
		pCurNode = itCur.m_pItem;

		// If resource is valid then free it from memory.
		if(itCur.IsResourceValid())
		{
			itCur->Destroy();
		}

		// Proceed to next element.
		itCur++;

		// Free node from memory.
		delete pCurNode;
	}

	// Reset attributes.
	m_pEnd = m_pLast = m_pBegin = NULL;
	m_nSize = NULL;
}

// Function Name:	ReleaseUnusedResources
//
// Author:			Lea Hayes
// Date Created:	12/03/2006
// Date Modified:	12/03/2006
//
// Description:		Release all unused resources.
//
void ResourceArray::ReleaseUnusedResources()
{
	// Iterate through each resource and free from memory.
	iterator itCur = Begin();
	LPLISTNODE pCurNode = NULL;

	while(itCur.IsValid())
	{
		// Preserve pointer to current element.
		pCurNode = itCur.m_pItem;

		// If resource is valid and is nolonger in use then release it
		// from memory.
		if(itCur.IsResourceValid() && !itCur->IsResourceBeingUsed())
		{
			itCur->Destroy();

			// Proceed to next element.
			itCur++;

			// Free node from memory.
			delete pCurNode;
		}
		else
		{
			// Proceed to next element.
			itCur++;
		}
	}

	// Reset attributes.
	m_pEnd = m_pLast = m_pBegin = NULL;
	m_nSize = NULL;
}


// ResourceArray - Resource handles and iterations.

const ResourceArray::ResHandle ResourceArray::NullHandle(NULL);
const ResourceArray::iterator ResourceArray::NullIterator(NULL);


// ResourceArray - Array manipulation.


// Function Name:	Insert
//
// Author:			Lea Hayes
// Date Created:	11/03/2006
// Date Modified:	11/03/2006
//
// Description:		Insert resource at specified location.
//
void ResourceArray::Insert(ResourceArray::iterator& itPos,
						   LPRESOURCE pRes)
{
	// Automatically update resource array structure where necessary.
	QueryUpdate();

	// Create new resource node and populate with resource.
	LPRESLISTNODE pNewNode = new ResListNode(pRes);
	pRes->Attach(this);

	// Link node into list.
	//

	// First assign the nodes previous and next pointers.
	pNewNode->m_pPrev = (*itPos)->m_pPrev;
	pNewNode->m_pNext = itPos;

	// If necessary attach beginning of list to node.
	if(m_pBegin == itPos.m_pItem)
	{
		m_pBegin = pNewNode;
	}

	// If the end of array node follows then attach this node to
	// the last node pointer. Otherwise if the last and end references
	// are identical then point last reference to that new node.
	//
	// Bug fix resulting from Test #003.
	//
	if(m_pEnd == itPos.m_pItem || m_pLast == m_pEnd)
	{
		m_pLast = pNewNode;
	}

	// Secondly assign the previous nodes' next reference to that of
	// the newly created node.
	if(!pNewNode->IsBeginNode())
	{
		pNewNode->m_pPrev->m_pNext = pNewNode;
	}

	// Finally assign the next nodes' previous reference to that of
	// the newly created node.
	pNewNode->m_pNext->m_pPrev = pNewNode;

	// Increment resource node size.
	m_nSize++;

	// Update all resource node indexes.
	UpdateIndexes();
}

// Function Name:	Append
//
// Author:			Lea Hayes
// Date Created:	11/03/2006
// Date Modified:	11/03/2006
//
// Description:		Append resource to end of array.
//
void ResourceArray::Append(LPRESOURCE pRes)
{
	// Insert resource at end of array.
	Insert(End(), pRes);
}

//// Function Name:	Aquire
////
//// Author:			Lea Hayes
//// Date Created:	12/03/2006
//// Date Modified:	12/03/2006
////
//// Description:		Aquire handle to resource.
////
//ResourceArray::ResHandle ResourceArray::Aquire(DWORD dwUniqueResID)
//{
//	// Retrieve resource by its unique resource ID.
//	iterator itCur = Begin();
//	iterator itEnd = End();
//
//	for(; itCur != itEnd; itCur++)
//	{
//		// If this unique resource ID matches then...
//		if(itCur->GetUniqueID() == dwUniqueResID)
//		{
//			// Aquire and return a resource handle.
//			return Aquire(itCur);
//		}
//	}
//
//	// Resource was not found.
//	return NullHandle;
//}

// Function Name:	Aquire
//
// Author:			Lea Hayes
// Date Created:	12/03/2006
// Date Modified:	12/03/2006
//
// Description:		Aquire handle to resource.
//
ResourceArray::ResHandle ResourceArray::Aquire(ResHandle& handle)
{
	// If resource handle is invalid then return a null handle.
	if(!handle.IsResourceValid())
		return NullHandle;

	// Aquire resource handle.
	handle->m_dwUsage++;

	// Return handle.
	return handle;
}

// Function Name:	Aquire
//
// Author:			Lea Hayes
// Date Created:	12/03/2006
// Date Modified:	12/03/2006
//
// Description:		Aquire handle to resource.
//
ResourceArray::ResHandle ResourceArray::AquireByIndex(size_t nIndex)
{
	// Generate a resource handle and aquire it.
	return Aquire(ResHandle(Begin() + nIndex));
}

// Function Name:	Release
//
// Author:			Lea Hayes
// Date Created:	11/03/2006
// Date Modified:	11/03/2006
//
// Description:		Release resource from array at specified location.
//
void ResourceArray::Release(iterator& itPos)
{
	// If resource is not valid then skip.
	if(!itPos.IsValid() || itPos == End())
		return;

	// Assume that the resource is nolonger required and then attempt to
	// proove that assumption wrong.
	bool bDestroy = true;

	// If resource is still in use then...
	if(itPos->IsResourceBeingUsed())
	{
		// Decrement usage counter and then determine whether or not the
		// resource is still in use.

		bDestroy = --itPos->m_dwUsage == 0;
	}

	// If resource is not to be destroyed then skip function.
	if(!bDestroy || !IsAutoFreeUnused())
		return;

	// Iterate through each resource and free from memory.
	LPLISTNODE pCurNode = itPos.m_pItem;

	// Before node is destroyed left and right nodes must be attached
	// together in some way.
	if(pCurNode->m_pPrev != NULL)
		pCurNode->m_pPrev->m_pNext = pCurNode->m_pNext;
	else
		m_pBegin = pCurNode->m_pNext;

	// There should always be a next node by this point because the
	// end node cannot be released directly.
	pCurNode->m_pNext->m_pPrev = pCurNode->m_pPrev;

	// If the node in question is referenced by the last pointer then
	// the last pointer must be maintained.
	if(m_pLast == pCurNode)
	{
		// Redirect the last node pointer to the element preeceding
		// the one being released.
		//
		// Bug fix resulting from Test #003.
		//
		if(pCurNode->m_pPrev != NULL)
			m_pLast = pCurNode->m_pPrev;
		else
			m_pLast = m_pEnd;
	}

	// If resource is valid then free it from memory.
	if(itPos.IsResourceValid())
	{
		itPos->Destroy();
	}

	// Free node from memory.
	delete pCurNode;

	itPos.m_pItem = NULL;

	// Decrement resource array size.
	m_nSize--;

	// Update all resource node indexes.
	UpdateIndexes();
}

// Function Name:	Release
//
// Author:			Lea Hayes
// Date Created:	11/03/2006
// Date Modified:	11/03/2006
//
// Description:		Release resource from array at specified location.
//
void ResourceArray::Release(size_t nIndex)
{
	// Release resource at index specified.
	Release(Begin() + nIndex);
}

// Function Name:	Release
//
// Author:			Lea Hayes
// Date Created:	11/03/2006
// Date Modified:	11/03/2006
//
// Description:		Release resource from array at specified location.
//
void ResourceArray::Release(LPRESOURCE pRes)
{
	// Find resource specified and release.
	iterator itRelease = Find(pRes);

	if(itRelease.IsValid())
	{
		Release(itRelease);
	}
}

// Function Name:	Find
//
// Author:			Lea Hayes
// Date Created:	11/03/2006
// Date Modified:	11/03/2006
//
// Description:		Retrieve iterator to resource specified; when not
//					found a NULL iterator is returned.
//
ResourceArray::iterator ResourceArray::Find(LPRESOURCE pRes)
{
	// If no resource has been specified then it will not be found
	// within the resource array; so suppress.

	if(pRes == NULL)
	{
		return NullIterator;
	}

	// Iterate through each resoucre until the specified resource is
	// found. If the resource is found then return an iterator to it.

	iterator itCur = Begin();
	iterator itEnd = End();

	for(; itCur != itEnd; itCur++)
	{
		if(pRes == (*itCur)->m_pRes)
		{
			// Return the resource iterator.
			return itCur;
		}
	}

	// Otherwise resource was not found.
	return NullIterator;
}

// Function Name:	Find
//
// Author:			Lea Hayes
// Date Created:	24/03/2006
// Date Modified:	24/03/2006
//
// Description:		Retrieve iterator to resource specified; when not
//					found a NULL iterator is returned.
//
ResourceArray::iterator ResourceArray::Find(DWORD dwUniqueID)
{
	// Iterate through each resource within the array specified.
	iterator itCur = Begin();
	iterator itEnd = End();

	for(; itCur != itEnd; itCur++)
	{
		// If resource has been found then return its handle.
		if(itCur->GetUniqueID() == dwUniqueID)
		{
			return itCur;
		}
	}

	// The resource was not found.
	return NullIterator;
}

// Function Name:	Find
//
// Author:			Lea Hayes
// Date Created:	12/03/2006
// Date Modified:	12/03/2006
//
// Description:		Retrieve iterator to resource specified; when not
//					found a NULL iterator is returned.
//
ResourceArray::iterator ResourceArray::Find(LPCSTR lpszFilePath)
{
	// Iterate through each resource within the array specified.
	iterator itCur = Begin();
	iterator itEnd = End();

	for(; itCur != itEnd; itCur++)
	{
		// If resource has been found then return its handle.
		if(!strcmp(itCur->GetFilePath(), lpszFilePath))
		{
			return itCur;
		}
	}

	// The resource was not found.
	return NullIterator;
}

// Function Name:	FindNext
//
// Author:			Lea Hayes
// Date Created:	24/03/2006
// Date Modified:	24/03/2006
//
// Description:		Retrieve iterator to next resource specified; when
//					not found a NULL iterator is returned.
//
ResourceArray::iterator ResourceArray::FindNext(const iterator& prev,
												DWORD dwUniqueResID)
{
	// Iterate through each resource within the array specified.
	iterator itCur = prev + 1;
	iterator itEnd = End();

	for(; itCur != itEnd; itCur++)
	{
		// If resource has been found then return its handle.
		if(itCur->GetUniqueID() == dwUniqueResID)
		{
			return itCur;
		}
	}

	// The resource was not found.
	return NullIterator;
}

// Function Name:	FindNext
//
// Author:			Lea Hayes
// Date Created:	24/03/2006
// Date Modified:	24/03/2006
//
// Description:		Retrieve iterator to next resource specified; when
//					not found a NULL iterator is returned.
//
ResourceArray::iterator ResourceArray::FindNext(const iterator& prev,
												LPCSTR lpszFilePath)
{
	// Iterate through each resource within the array specified.
	iterator itCur = prev + 1;
	iterator itEnd = End();

	for(; itCur != itEnd; itCur++)
	{
		// If resource has been found then return its handle.
		if(!strcmp(itCur->GetFilePath(), lpszFilePath))
		{
			return itCur;
		}
	}

	// The resource was not found.
	return NullIterator;
}


// ResourceArray - Link list nodes and helper functions.


// Function Name:	CreateDummyNode
//
// Author:			Lea Hayes
// Date Created:	10/03/2006
// Date Modified:	10/03/2006
//
// Description:		Create dummy node to represent end of list.
//
void ResourceArray::CreateDummyNode()
{
	// If list is already linked to one or more nodes then they
	// must first be destroyed.
	if(m_pBegin != NULL)
	{
		Destroy();
	}

	// Create dummy node and attach to list.
	m_pEnd = m_pLast = m_pBegin = new ListNode;
	m_nSize = NULL;
}

// Function Name:	QueryUpdate
//
// Author:			Lea Hayes
// Date Created:	11/03/2006
// Date Modified:	11/03/2006
//
// Description:		Check integrity of resource array.
//
void ResourceArray::QueryUpdate()
{
	// If necessary create the dummy end node.
	if(GetCount() == NULL && m_pBegin == NULL)
	{
		CreateDummyNode();
	}
}

// Function Name:	UpdateIndexes
//
// Author:			Lea Hayes
// Date Created:	11/03/2006
// Date Modified:	11/03/2006
//
// Description:		Update resource node index values.
//
void ResourceArray::UpdateIndexes()
{
	// Iterate through each resource and update its respective node
	// index value.

	iterator itCur = Begin();

	// i <= GetCount();		// Update dummy nodes index value as well.
	for(size_t i = 0; i <= GetCount(); i++, itCur++)
	{
		(*itCur)->m_nIndex = i;
	}
}


// ResourceArray - Properties.


// Function Name:	EnableAutoFreeUnused
//
// Author:			Lea Hayes
// Date Created:	12/03/2006
// Date Modified:	12/03/2006
//
// Description:		Update resource node index values.
//
bool ResourceArray::EnableAutoFreeUnused(bool bEnable /*=true*/)
{
	// If flag has not changed then skip.
	if(m_bAutoFree == bEnable)
		return bEnable;

	// Preserve current flag value for return.
	bool bPrevFlag = m_bAutoFree;

	// Update flag.
	m_bAutoFree = bEnable;

	// If auto free has been enabled then it is possible that
	// their are unused resources are being stored.
	if(m_bAutoFree)
	{
		// Release any unused resources.
		ReleaseUnusedResources();
	}

	// Return previous value.
	return bPrevFlag;
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久狠狠亚洲综合| 最好看的中文字幕久久| 日本午夜一本久久久综合| 精品一区免费av| 精品久久久久一区二区国产| 激情都市一区二区| 久久综合九色综合久久久精品综合| 亚洲成av人片在线观看| 在线成人av网站| 久久99国产精品免费| 欧美日韩国产综合一区二区 | 99久久精品免费观看| 中文字幕一区三区| av电影在线观看完整版一区二区| www久久久久| 国精产品一区一区三区mba视频| 亚洲视频一区二区在线观看| 色婷婷国产精品| 亚洲自拍偷拍综合| 欧美精品视频www在线观看| 男女男精品视频网| 国产亚洲人成网站| 91麻豆swag| 日韩国产欧美在线播放| www国产精品av| 95精品视频在线| 午夜精品一区二区三区电影天堂| 制服.丝袜.亚洲.另类.中文| 国模一区二区三区白浆| 国产婷婷色一区二区三区在线| av综合在线播放| 久久电影网电视剧免费观看| 亚洲欧洲日韩一区二区三区| 欧美日韩国产小视频在线观看| 国产真实乱偷精品视频免| 亚洲色图另类专区| 久久众筹精品私拍模特| 韩国成人在线视频| 中文字幕在线观看不卡视频| 91视频在线观看免费| 欧美国产一区二区| av成人老司机| 国产麻豆精品一区二区| 亚洲成a人片在线不卡一二三区| 久久精品亚洲一区二区三区浴池 | 亚洲成人三级小说| 欧美激情艳妇裸体舞| 91精品国产日韩91久久久久久| 成人黄动漫网站免费app| 美女视频免费一区| 亚洲国产日日夜夜| 国产精品国产三级国产普通话99| 欧美大片一区二区| 在线观看www91| 99国内精品久久| 国产成人亚洲综合a∨猫咪| 天堂一区二区在线| 亚洲一区成人在线| 亚洲美女少妇撒尿| 国产精品毛片久久久久久| 99久久久精品| 激情五月播播久久久精品| 毛片不卡一区二区| 日韩黄色免费网站| 亚洲韩国精品一区| 亚洲码国产岛国毛片在线| 国产精品丝袜久久久久久app| 26uuu另类欧美| 欧美一级二级三级蜜桃| 欧美系列一区二区| 色婷婷久久一区二区三区麻豆| 国产91露脸合集magnet | 91麻豆精品国产91久久久久久久久 | 成人性生交大片免费看视频在线 | 亚洲欧洲综合另类在线| 久久久久久久久久久电影| 久久综合色8888| 久久久久国产精品免费免费搜索| 2022国产精品视频| www国产成人| 久久久精品tv| 无码av免费一区二区三区试看| 亚洲国产精品一区二区www在线| 激情综合色播五月| 国产成人综合网| 日韩激情在线观看| 奇米影视在线99精品| 一区二区免费在线| 国产乱人伦精品一区二区在线观看| 成人国产精品视频| 欧美一二三区在线观看| 欧美精品一区二区三| 亚洲午夜精品在线| 日本亚洲天堂网| 91视频91自| 欧美精品三级日韩久久| 日韩女优视频免费观看| 亚洲精品视频自拍| 日本va欧美va瓶| 国产精品久久毛片| 韩国女主播一区| av电影在线观看一区| 精品日韩欧美在线| 久久久久久一级片| 热久久久久久久| 99热99精品| 色综合久久久网| 国产免费久久精品| 一区二区视频免费在线观看| 国产盗摄一区二区三区| 色综合色狠狠综合色| 欧美高清视频一二三区 | 日韩高清不卡一区| 国内久久婷婷综合| 91精品福利在线一区二区三区| 久久久影院官网| 亚洲国产视频a| 国产一区二区三区国产| 成人天堂资源www在线| 欧美福利视频导航| 国产欧美日韩亚州综合| 懂色av一区二区三区免费观看| 国产精品午夜春色av| 色婷婷亚洲综合| 精品中文字幕一区二区| 国产精品成人免费在线| 欧美午夜精品一区二区三区| 蜜臀av亚洲一区中文字幕| 一区2区3区在线看| 国产日产精品1区| 亚洲精品一区二区在线观看| 91福利国产成人精品照片| 成人综合在线视频| 国产中文字幕一区| 美女精品一区二区| 日韩av午夜在线观看| 中文字幕亚洲区| 亚洲色图色小说| 国产精品的网站| 亚洲欧美另类小说视频| 国产精品国产a级| 亚洲欧洲av另类| 亚洲另类色综合网站| 亚洲另类一区二区| 中文字幕人成不卡一区| 国产精品久久久久久妇女6080| 久久久久久久久伊人| 欧美国产日韩a欧美在线观看| www一区二区| 中文字幕综合网| 午夜电影久久久| 国产一区二区三区| 色吧成人激情小说| 日韩一区二区精品在线观看| 精品成a人在线观看| 亚洲乱码日产精品bd| 午夜影院在线观看欧美| 国产精品综合一区二区三区| 不卡欧美aaaaa| 日韩一区二区三区视频在线 | 老司机免费视频一区二区三区| 视频一区在线播放| 成人黄色综合网站| 日韩一区和二区| 亚洲天堂av一区| 国产在线播放一区三区四| 在线精品视频免费播放| 蜜桃视频在线一区| 91免费精品国自产拍在线不卡 | 久久综合九色综合久久久精品综合| 久久精品亚洲一区二区三区浴池| 亚洲黄色小视频| 99久久婷婷国产| 中文字幕乱码亚洲精品一区 | 亚洲一区成人在线| 91无套直看片红桃| 中文字幕一区在线| 成人国产免费视频| 国产精品嫩草影院com| 极品少妇xxxx精品少妇| 日韩精品一区在线观看| 日本午夜精品视频在线观看| 欧美日韩一级黄| 精品一区二区免费看| 精品国产乱码久久久久久影片| 人人狠狠综合久久亚洲| 欧美成人官网二区| 国产精品综合在线视频| 久久精品视频一区二区三区| 欧美在线影院一区二区| 五月天亚洲婷婷| 久久一区二区三区国产精品| 成人精品免费看| 亚洲第一激情av| 欧美精品一区二区三区在线播放 | 欧美日韩久久一区| 久久精品免费看| 亚洲一区二区三区中文字幕 | 欧美国产精品久久| 日本久久电影网|