﻿package com.adobe.captivate
{

import com.adobe.captivate.core.cpVariablesHandle;
import com.adobe.captivate.core.cpInterfaceManager;
import com.adobe.captivate.core.enums.cpInterfaceEnum;
import com.adobe.captivate.core.cp_internal;

use namespace cp_internal;

public dynamic class cpUserVariableHandle extends cpVariablesHandle
{
	private static var m_Instance:cpUserVariableHandle;
	VAR_CLASS_STMNTS;
	function cpUserVariableHandle(aBlocker:cpUserVariableHandleCreatorBlocker)
	{
		super(this);
		VAR_CONSTRUCTOR_STMNTS;
		if(aBlocker == null)
		{
			throw new Error("cpUserVariableHandle tried to be created illegaly");
		}
		cpInterfaceManager.getInstance().registerInterface(cpInterfaceEnum.VariableHandle_Interface,this);
		
	}

	override protected function StoreVariableValue(variableName:String,variableValue:Object):Object
	{
		var lOldValue:Object = null;
		if(variableName.length)
		{
			lOldValue = this[variableName];
			this[variableName] = variableValue;
		}
		return lOldValue;
	}
	
	static function getInstance():cpUserVariableHandle
	{
		if(m_Instance == null)
		{
			m_Instance = new cpUserVariableHandle(new cpUserVariableHandleCreatorBlocker());
		}
		return m_Instance;
	}
	VAR_GETTERSETTER_STMNTS;
}
}
internal class cpUserVariableHandleCreatorBlocker{}
