//----------------------------------------------------------------------------- // // File: smartptr.inl // Copyright (C) 1994-1997 Microsoft Corporation // All rights reserved. // // // //----------------------------------------------------------------------------- template SmartPtr< T >::SmartPtr() { m_pObject = NULL; } template SmartPtr< T >::SmartPtr( T *pObject) { m_pObject = pObject; } template T & SmartPtr< T >::operator*(void) const { LTASSERT(m_pObject != NULL); return *m_pObject; } template T * SmartPtr< T >::operator->(void) const { LTASSERT(m_pObject != NULL); return m_pObject; } template T * SmartPtr< T >::Extract(void) { T *pObj = m_pObject; m_pObject = NULL; return pObj; } template T* SmartPtr< T >::GetPointer(void) { return m_pObject; } template const T* SmartPtr< T >::GetPointer(void) const { return m_pObject; } template BOOL SmartPtr< T >::IsNull(void) const { return m_pObject == NULL; } template void SmartPtr< T >::operator=( T *pObject) { LTASSERT(m_pObject == NULL); if (m_pObject != NULL) { delete m_pObject; } m_pObject = pObject; } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // This should only be used to init a smart pointer. // //----------------------------------------------------------------------------- template SmartPtr< T >::operator T * & (void) { LTASSERT(m_pObject == NULL); return m_pObject; } template void SmartPtr< T >::operator delete( void *) { LTASSERT(m_pObject != NULL); delete m_pObject; m_pObject = NULL; } template SmartPtr< T >::~SmartPtr() { if (m_pObject != NULL) { delete m_pObject; } }