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

📄 resarrayhandle.h

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

// Author:			Lea Hayes
// Date Created:	12/03/2006
// Date Modified:	12/03/2006

#pragma once

#include "ResListNode.h"

#include "DirectXTexture.h"
#include "DirectXObject.h"
#include "DirectXFont.h"


namespace Resources
{


class ResArrayHandle
{
// Construction and deconstruction.
public:
	ResArrayHandle(LPRESLISTNODE pNode);
	ResArrayHandle(const ResArrayHandle &handle);
	virtual ~ResArrayHandle();

// Properties.
	inline bool IsValid() const
	{
		return m_pItem != NULL;
	}
	inline bool IsResourceValid() const
	{
		return IsValid() && m_pItem->IsResourceValid();
	}

	inline LPRESOURCE GetResource()
	{
		return IsValid() ? m_pItem->m_pRes : NULL;
	}

	inline size_t GetIndex() const
	{
		return IsValid() ? m_pItem->GetIndex() : NULL;
	}

// Helper inline type-casting functions.
	inline DirectXTexture* ToDirectXTexture()
	{
		return reinterpret_cast<DirectXTexture*>(GetResource());
	}
	inline DirectXObject* ToDirectXObject()
	{
		return reinterpret_cast<DirectXObject*>(GetResource());
	}
	inline DirectXFont* ToDirectXFont()
	{
		return reinterpret_cast<DirectXFont*>(GetResource());
	}

// Operator overloads.
	inline bool operator== (const ResArrayHandle& handle)
	{
		return m_pItem == handle.m_pItem;
	}
	inline bool operator!= (const ResArrayHandle& handle)
	{
		return m_pItem != handle.m_pItem;
	}


	inline LPRESOURCE operator*()
	{
		return m_pItem->m_pRes;
	}
	inline LPRESOURCE operator-> ()
	{
		return m_pItem->m_pRes;
	}
	inline operator LPRESLISTNODE ()
	{
		return m_pItem;
	}

// Only resource arrays and of course the iterator itself have access to
// protected iterator members.

	friend class ResourceArray;

// Attributes.
protected:
	LPRESLISTNODE m_pItem;			// Pointer to array item.
};


}; // namespace Resources

⌨️ 快捷键说明

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