当前位置: 首页>>代码示例>>C++>>正文


C++ EventType::GetHash方法代码示例

本文整理汇总了C++中EventType::GetHash方法的典型用法代码示例。如果您正苦于以下问题:C++ EventType::GetHash方法的具体用法?C++ EventType::GetHash怎么用?C++ EventType::GetHash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventType的用法示例。


在下文中一共展示了EventType::GetHash方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: VRemoveListener

// *****************************************************************************
void cEventManager::VRemoveListener(const EventListenerCallBackFn & fnListener,
	const EventType & eventType)
{
	bool success = false;
	Log_Write(ILogger::LT_EVENT, 2, "Attempting to remove delegate function from event type " + eventType.GetString());
	
	EventListenerList & eventListeners = m_eventListeners[eventType.GetHash()];

	auto findIt = m_eventListeners.find(eventType.GetHash());
    if (findIt != m_eventListeners.end())
	{
		EventListenerList & listeners = findIt->second;
		for (auto it = listeners.begin(); it != listeners.end(); it++)
		{
			if (fnListener == (*it))
			{
				listeners.erase(it);
				Log_Write(ILogger::LT_EVENT, 2, "Successfully removed delegate for event type " + eventType.GetString());
				return;
			}
		}
	}

	if(!success)
	{
		Log_Write(ILogger::LT_WARNING, 2, "Attempting to double-register a listener for event " + eventType.GetString());
	}
}
开发者ID:AnkurSheel,项目名称:Engine,代码行数:29,代码来源:EventManager.cpp

示例2: VAbortEvent

// *****************************************************************************
void cEventManager::VAbortEvent(const EventType & eventType, const bool allEVents)
{
	EventListenerMap::iterator findIt = m_eventListeners.find(eventType.GetHash());

	if (findIt != m_eventListeners.end())
    {
        EventQueue& eventQueue = m_queues[m_activeQueue];
        auto it = eventQueue.begin();
        while (it != eventQueue.end())
        {
            // Removing an item from the queue will invalidate the iterator, so have it point to the next member.  All
            // work inside this loop will be done using thisIt.
            auto thisIt = it;
            ++it;

			if ((*thisIt)->VGetEventID() == eventType.GetHash())
	        {
		        eventQueue.erase(thisIt);
		        if (!allEVents)
			        break;
	        }
        }
    }
}
开发者ID:AnkurSheel,项目名称:Engine,代码行数:25,代码来源:EventManager.cpp

示例3: VAddListener

// *****************************************************************************
void cEventManager::VAddListener(const EventListenerCallBackFn & fnListener,
	const EventType & eventType)
{
	Log_Write(ILogger::LT_EVENT, 2, "Attempting to add listener for event " + eventType.GetString());
	
	EventListenerList & eventListeners = m_eventListeners[eventType.GetHash()];

    for (auto it = eventListeners.begin(); it != eventListeners.end(); it++)
    {
		if (fnListener.target_type() == (*it).target_type())
        {
			Log_Write(ILogger::LT_WARNING, 2, "Attempting to double-register a listener for event " + eventType.GetString());
            return;
        }
    }

	eventListeners.push_back(fnListener);
	Log_Write(ILogger::LT_EVENT, 2, "Successfully added delegate for event type " + eventType.GetString());
}
开发者ID:AnkurSheel,项目名称:Engine,代码行数:20,代码来源:EventManager.cpp


注:本文中的EventType::GetHash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。