resarrayhandle.h

来自「这个是我第一次完成的一个简单的3D ALIEN SHOOTING GAME的RE」· C头文件 代码 · 共 99 行

H
99 行
字号
// 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 + =
减小字号Ctrl + -
显示快捷键?