//===========================================================================//
// File:	GlobalPointerManager.hpp                                        
// Project: Adept
// Contents: GlobalPointers	
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               
// --------  ---  -----------------------------------------------------------//
// 07/08/00  JSE  Initial Coding
//---------------------------------------------------------------------------//
// Copyright (C) 2000, Microsoft Corp.							             
// All Rights reserved worldwide                                            
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL              
//===========================================================================//

#pragma once

#include "Adept.hpp"

#if 0
#define GLOBAL_POINTER(string) LOGIC("GlobalPointer::" string)
#else
#define GLOBAL_POINTER(string)
#endif

namespace Adept 
{


	void AdeptGlobalPointerSecurityCheckStart();
	void AdeptGlobalPointerSecurityCheckStop();


	class GlobalPointers 
	{
	public:

		static void	InitializeClass();
		static void TerminateClass();

		static GlobalPointers *globalPointer;
		static int *globalKey;

		static void ClearPointer(int pointer_index);
		static void AddGlobalPointer(void *pointer, int pointer_index);
		static void MoveGlobals();

		void *m_pointerArray[30];
		
		static void *GlobalPointers::GetGlobalPointer(int pointer_number)
		{
			GLOBAL_POINTER("Get");
			//GlobalPointers *pointer = globalPointer ^ *globalKey;
			GlobalPointers *pointer = Cast_Pointer(GlobalPointers *, ((int)globalPointer ^ *globalKey));
			return reinterpret_cast<void*>( ((int)pointer->m_pointerArray[pointer_number] ^ 0x85739531));
		}

	};

}