Search Results for 'SmartPointer'

ATOM Icon

1 POSTS

  1. 2008/10/25 SmartPointer by chungki (2)

SmartPointer

template 
class SmartP
{

	class CReference
	{

	public:

		CReference() : m_RefCount(0) {}
		virtual ~CReference() {m_RefCount=0;}

		void	IncRef() {m_RefCount++;}
		bool	DecRef()
		{
			if ((--m_RefCount)==0)
				return true;

			return false;
		}

		void	Release() {delete this;}

	private:

		u32	m_RefCount;
	};

public:

	typedef _T*				pointertype;
	typedef const _T*		const_interfacetype;
	typedef CReference*		referencetype;

public:

	pointertype		m_Pointer;
	referencetype	m_Reference;

public:

	SmartP();
	SmartP(IN pointertype _Interface);
	SmartP(IN const SmartP<_T>& _SmartI);
	virtual ~SmartP();

public:

	const pointertype	GetPointer() const {return m_Pointer;}
	const referencetype	GetReference() const {return m_Reference;}

private:

	void __Create(IN pointertype _Pointer);
	void __Destroy();

public:

	SmartP<_T> operator =(IN pointertype _Pointer);
	SmartP<_T> operator =(IN const SmartP<_T>& _SmartP);

	bool  operator ==(IN const SmartP<_T>& _SmartP);
	bool  operator ==(IN const pointertype _Pointer);
	bool  operator !=(IN const SmartP<_T>& _SmartP);
	bool  operator !=(IN const pointertype _Pointer);

	pointertype		operator ->() {return m_Pointer;}
	const_interfacetype	operator ->() const {return m_Pointer;}

	operator pointertype()				{return m_Pointer;}
	operator const_interfacetype() const	{return m_Pointer;}

};

Posted by chungki

2008/10/25 23:24 2008/10/25 23:24
,
Response
No Trackback , 2 Comments
RSS :
http://www.chungki.net/tc/rss/response/264


블로그 이미지

Nice !!!!!!!!

- chungki

Notices

Archives

Authors

  1. chungki

Calendar

«   2012/05   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Site Stats

Total hits:
73376
Today:
7
Yesterday:
20