templateclass 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


