view LightClone/Source/GuiEventMap.cpp @ 75:57c0ce406a68 tip

Add main menu
author koryspansel <koryspansel@bendbroadband.com>
date Tue, 18 Oct 2011 17:08:17 -0700
parents 8e7ebab350e7
children
line wrap: on
line source

/*
 * GuiEventMap
 */

#include "GuiEventMap.h"

/* 
 * GuiEventMap
 */
GuiEventMap::GuiEventMap()
{
}

/* 
 * ~GuiEventMap
 */
GuiEventMap::~GuiEventMap()
{
	GuiEventHashMap::Iterator kEvent	= kMap.Begin();
	GuiEventHashMap::Iterator kEventEnd	= kMap.End();

	for(; kEvent != kEventEnd; ++kEvent)
	{
		delete *kEvent;
	}
}

/*
 * Fire
 */
void GuiEventMap::Fire(const char* pName, GuiEventArguments& kArguments)
{
	GuiEvent* pEvent = GetEvent(pName);
	if(pEvent)
	{
		pEvent->Fire(kArguments);
	}
}

/*
 * GetEvent
 */
GuiEvent* GuiEventMap::GetEvent(const char* pName, bool bAdd)
{
	GuiEvent** pEvent = kMap.Find(FixedString<>(pName));
	if(!pEvent)
	{
		if(bAdd)
		{
			pEvent = kMap.Add(FixedString<>(pName));
			if(pEvent)
			{
				*pEvent = new GuiEvent(pName);
			}
		}
	}

	return pEvent ? *pEvent : NULL;
}