view LightClone/Source/Code.cpp @ 25:eae13b04b06f

Working on Gui drag and drop
author koryspansel <koryspansel@bendbroadband.com>
date Fri, 16 Sep 2011 13:11:35 -0700
parents 7e3a0ae9c016
children
line wrap: on
line source

/*
 * Code
 */

#include "Code.h"

/*
 * Code
 */
Code::Code()
{
	pSlot	= 0;
	nSize	= 0;
	nLength	= 0;
}

/*
 * Initialize
 */
void Code::Initialize(uint32 nValue)
{
	if(pSlot)
	{
		delete[] pSlot;
		pSlot = 0;
	}

	nLength	= 0;
	nSize	= nValue;
	pSlot	= new uint32[nValue];

	Clear();
}

/*
 * Clear
 */
void Code::Clear()
{
	for(uint32 i = 0; i < nSize; ++i)
	{
		pSlot[i] = 0;
	}
}

/*
 * SetSlot
 */
void Code::SetSlot(uint32 nSlot, uint32 nValue)
{
	if(nSlot < nSize)
	{
		pSlot[nSlot] = nValue;
	}
}

/*
 * GetSlot
 */
uint32 Code::GetSlot(uint32 nSlot)
{
	return nSlot < nSize ? pSlot[nSlot] : 0;
}

/*
 * ClearSlot
 */
void Code::ClearSlot(uint32 nSlot)
{
	if(nSlot < nSize)
	{
		pSlot[nSlot] = 0;
	}
}

/*
 * IsEmptySlot
 */
bool Code::IsEmptySlot(uint32 nSlot) const
{
	return nSlot < nSize ? (pSlot[nSlot] < Action_Forward || pSlot[nSlot] > Action_Light) : true;
}

/*
 * GetSize
 */
uint32 Code::GetSize() const
{
	return nSize;
}

/*
 * GetLength
 */
uint32 Code::GetLength() const
{
	uint32 nLength = 0;

	for(uint32 i = 0; i < nSize; ++i)
	{
		if(pSlot[nLength] != 0)
		{
			++nLength;
		}
	}

	return nLength;
}