/// /// Copyright © 2003-2008 JetBrains s.r.o. /// You may distribute under the terms of the GNU General Public License, as published by the Free Software Foundation, version 2 (see License.txt in the repository root folder). /// #pragma unmanaged #ifdef EMAPI_MANAGED #pragma managed #endif template< typename T > RCPtr::RCPtr( T* realPtr = NULL ) : pointee( realPtr ) { init(); } template< typename T > RCPtr::RCPtr( const RCPtr& rhs ) : pointee( rhs.pointee ) { init(); } template< typename T > RCPtr::~RCPtr() { try { if ( pointee != 0 ) { pointee->removeRef(); } } catch(...)//trap all exceptions in destructor {} } template< typename T > RCPtr& RCPtr::operator=( const RCPtr& rhs ) { if ( pointee != rhs.pointee ) { T* oldPointee = pointee; pointee = rhs.pointee; init(); if ( oldPointee != 0 ) { oldPointee->removeRef(); } } return *this; } template< typename T > T* RCPtr::operator->() const { return pointee; } template< typename T > T* RCPtr::get() const { return pointee; } template< typename T > T& RCPtr::operator*() const { return *pointee; } template< typename T > bool RCPtr::IsNull() const { return ( pointee == 0 ); } template< typename T > void RCPtr::release() { if ( pointee != 0 ) { if ( pointee->removeRef() == 0 ) { pointee = 0; } } } template< typename T > int RCPtr::GetRefCount() const { if ( pointee != 0 ) { return pointee->GetRefCount(); } return 0; } template< typename T > void RCPtr::init() { if ( pointee == 0 ) return; pointee->addRef(); } template< typename T > RCPtr* RCPtr::CloneOnHeap() const { return new RCPtr( *this ); }