Mercurial > LightClone
view LightClone/Source/GuiEventMap.h @ 53:8cefb65577cc
Clean up world states
author | koryspansel |
---|---|
date | Fri, 30 Sep 2011 15:23:16 -0700 |
parents | 3a63df04f3c0 |
children | 8e7ebab350e7 |
line wrap: on
line source
/* * GuiEventMap */ #ifndef __GUIEVENTMAP_H__ #define __GUIEVENTMAP_H__ #include "Core.h" #include "GuiEvent.h" #include "HashMap.h" /* * GuiEventMap */ class GuiEventMap { /* * kMap */ HashMap<FixedString<>, GuiEvent*, FixedString<>::Hash> kMap; public: /* * GuiEventMap */ GuiEventMap(); /* * Subscribe */ ErrorCode Subscribe(const char* pName, void (*pFunction)(GuiEventArguments&)) { GuiEvent* pEvent = GetEvent(pName, true); if(pEvent) { return pEvent->Subscribe(pFunction), Error_Success; } return Error_Fail; } /* * Subscribe */ template<typename Type> ErrorCode Subscribe(const char* pName, void (Type::*pFunction)(GuiEventArguments&), Type* pInstance) { GuiEvent* pEvent = GetEvent(pName, true); if(pEvent) { return pEvent->Subscribe(pFunction, pInstance), Error_Success; } return Error_Fail; } /* * Fire */ void Fire(const char* pEvent, GuiEventArguments& kArguments); private: /* * GetEvent */ GuiEvent* GetEvent(const char* pName, bool bAdd = false); }; #endif //__GUIEVENTMAP_H__