/****************************************************************************************************

		MacPointers.h
		Copyright: (c) 2002 Eovia Corp. All rights reserved.

		Author:	Arnaud
		Date:	12/14/2006

****************************************************************************************************/

#ifndef __MacPointers__
#define __MacPointers__

#if CP_PRAGMA_ONCE
#pragma once
#endif


//These classes are also used on windows (with the quicktime sdk)


//so we don't forget the CFRelease...
template <class MacRef> class CFMacPtr
{
public:
	CFMacPtr(MacRef inMacRef) 
	{
		fMacRef= inMacRef;
	}
	
	~CFMacPtr() 
	{
		if (fMacRef)
		{
			CFRelease(fMacRef);
			fMacRef= NULL;
		}
	}
	
	operator MacRef () 	{  return fMacRef; }	

private:
	MacRef fMacRef;
};



template <class MacHandle> class CFMacHandle
{
public:
	CFMacHandle(MacHandle inMacRef= NULL) 
	{
		fMacHandle= inMacRef;
	}
	
	~CFMacHandle() 
	{
		if (fMacHandle)
		{
			DisposeHandle(fMacHandle);
			fMacHandle= NULL;
		}
	}
	
	operator MacHandle& () 	{  return fMacHandle; }	

private:
	MacHandle fMacHandle;
};



#endif
