本文整理汇总了C++中EventType::GetIdent方法的典型用法代码示例。如果您正苦于以下问题:C++ EventType::GetIdent方法的具体用法?C++ EventType::GetIdent怎么用?C++ EventType::GetIdent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventType
的用法示例。
在下文中一共展示了EventType::GetIdent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RegisterEvent
//------------------------------------------------------------------------|
bool EventManager::RegisterEvent(EventType const& Type, IEventHandler* pHandler)
{
if(!ValidateType(Type))
return false;
EventHandlerMap::iterator elmIt = m_Registry.find(Type.GetIdent());
// If this event is not registered at all yet, initialize a list of handlers for this event.
if(elmIt == m_Registry.end())
{
EventHandlerMapIRes elmIRes = m_Registry.insert(
EventHandlerMapEnt(Type.GetIdent(), EventHandlerTable()));
if(!elmIRes.second)
return false;
if(elmIRes.first == m_Registry.end())
return false;
elmIt = elmIRes.first;
}
EventHandlerTable& evhTable = (*elmIt).second;
// Check if event is already registered
for(EventHandlerTable::iterator it = evhTable.begin(), itEnd = evhTable.end(); it != itEnd; it++)
{
bool bHandlerMatch = (*it == pHandler);
if(bHandlerMatch)
return false;
}
evhTable.push_back(pHandler);
return true;
}
示例2: UnregisterEvent
//------------------------------------------------------------------------|
bool EventManager::UnregisterEvent(EventType const& Type, IEventHandler* pHandler)
{
if(!ValidateType(Type))
return false;
bool rc = false;
// Find the currently registered handlers for the event.
EventHandlerMap::iterator elmIt = m_Registry.find(Type.GetIdent());
if(elmIt != m_Registry.end())
{
EventHandlerTable& table = elmIt->second;
for(EventHandlerTable::iterator it2 = table.begin(), it2End = table.end(); it2 != it2End; it2++)
{
if(*it2 == pHandler)
{
table.erase(it2);
rc = true;
break;
}
}
}
return rc;
}
示例3: ValidateType
//------------------------------------------------------------------------|
bool EventManager::ValidateType(EventType const& Type) const
{
if(0 == Type.GetStr().length())
return false;
if(Type == skAllEvents)
return true;
if(Type.GetIdent() == 0 && wcscmp(Type.GetStr().c_str(), skpWildCardEventType) == 0)
return false;
EventTypeSet::const_iterator evIt = m_TypeList.find(Type);
if(evIt == m_TypeList.end())
return false;
return true;
}