⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iresource.cpp

📁 这个是我第一次完成的一个简单的3D ALIEN SHOOTING GAME的RESOURCE MANAGER部分,大家可以看看,然后提点意见~THX
💻 CPP
字号:
// IResource.cpp
//

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

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

using namespace Resources;


// IResource - Construction and destruction.

IResource::IResource()
: m_dwUsage(NULL)
, m_pArray(NULL)
, m_szFilePath(NULL)
{
}

IResource::~IResource()
{
	// Clear any current file and path string.
	if(m_szFilePath != NULL)
		delete[] m_szFilePath;
}


// IResource - Memory management.


// Function Name:	Aquire
//
// Author:			Lea Hayes
// Date Created:	12/03/2006
// Date Modified:	12/03/2006
//
// Description:		Acquire usage of resource.
//
void IResource::Acquire(DWORD dwAddUsage /*=1U*/)
{
	// Increment resource usage.
	m_dwUsage += dwAddUsage;
}

// Function Name:	Release
//
// Author:			Lea Hayes
// Date Created:	10/03/2006
// Date Modified:	12/03/2006
//
// Description:		Automatically free resource from memory and
//					remove from the resource manager.
//
void IResource::Release()
{
	// Release resource via its associated container.
	reinterpret_cast<LPRESOURCEARRAY>(m_pArray)->Release(this);
}

// Function Name:	OnDestroy
//
// Author:			Lea Hayes
// Date Created:	26/03/2006
// Date Modified:	26/03/2006
//
// Description:		Event handler upon destruction.
//
void IResource::OnDestroy()
{
}


// IResource - Protected members.


// Function Name:	Destroy
//
// Author:			Lea Hayes
// Date Created:	10/03/2006
// Date Modified:	10/03/2006
//
// Description:		Destroy resource and invoke the event handler.
//					Note: Resource cleans its own memory.
//
void IResource::Destroy()
{
	// Execute event handler.
	OnDestroy();

	// Finally free resources own memory.
	delete this;
}

// Function Name:	SetFilePath
//
// Author:			Lea Hayes
// Date Created:	12/03/2006
// Date Modified:	12/03/2006
//
// Description:		Adjust resource file and path.
//
void IResource::SetFilePath(LPCSTR lpszFilePath)
{
	// Clear any current file and path string.
	if(m_szFilePath != NULL)
		delete[] m_szFilePath;

	// Store filename and path.
	m_szFilePath = new char[strlen(lpszFilePath) + 1];
	strcpy(m_szFilePath, lpszFilePath);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -