//====START_GENERATED_PROLOG======================================
//
//
//   COMPONENT_NAME: odutils
//
//   CLASSES: none
//
//   ORIGINS: 82,27
//
//
//   (C) COPYRIGHT International Business Machines Corp. 1995,1996
//   All Rights Reserved
//   Licensed Materials - Property of IBM
//   US Government Users Restricted Rights - Use, duplication or
//   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//   	
//   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
//   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
//   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
//   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
//   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
//   OR PERFORMANCE OF THIS SOFTWARE.
//
//====END_GENERATED_PROLOG========================================
//
// @(#) 1.5 com/src/utils/include/TempRef.th, odutils, od96nt, odnt9712d 3/14/97 16:56:33 [ 3/21/97 16:50:26 ]
/*
#	File:		TempRef.th
#
#	Contains:	Internal header for use by TempObj.h
#
#	Owned by:	Jens Alfke
#
#	Copyright:	(C) 1995 by Apple Computer, Inc., all rights reserved.
#
#	
#	In Progress:
#		
*/

// This header is a utility used by TempObj.h. Do not include it directly unless you
// really know what you're doing -- see the Tech Note "Temporary Objects/References".

#ifndef SOM_ODDocument_xh
#include <Document.xh>
#endif

#ifndef _T_
#error _T_ must be defined before including a .th file
#endif
#ifndef _C_
#error _C_ must be defined before including a .th file
#endif

//===========================================================================
//	TempObj <T>
//===========================================================================

#ifdef _TMPL_IMPL_

	// Implementation of the TempRef constructor:
	WIN32_DLLEXPORT _C_::_C_( _T_ *obj )
	{
		fObj = obj;
	}

	WIN32_DLLEXPORT _C_::~_C_( )
	{
		// Prevent compiler from inlining synthesized destructor
		// which causes code bloat.
	}

#else

	#if defined(__SC__) || defined(__MRC__)
	// Some of the typecasts below offend certain compilers.
	#pragma options(!warn_cast_incomplete_type)
	#endif

	// Declaration of the TempRef class
	class _C_ :public BaseTempRef
	{
		public:
		_DLLIMPORTEXPORT_ _C_( _T_* );
		_DLLIMPORTEXPORT_ virtual ~_C_( );
		_T_* operator-> ()			{return (_T_*)fObj;}
		operator _T_* ()			{return (_T_*)fObj;}
		_T_* operator=( _T_ *t )	{fObj=(ODRefCntObject*)t; return t;}
		
		_T_* DontRelease()			{_T_* temp=(_T_*)fObj; fObj=kODNULL; return temp;}
	};

	#if defined(__SC__) || defined(__MRC__)
	#pragma options(warn_cast_incomplete_type)	// undo previous pragma
	#endif
#endif

#undef _T_
#undef _C_

