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


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

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


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

示例1: VValidateType

//
// EventManager::VValidateType			- Chapter 10, page 299
//
// Validate an event type, this does NOT add it to the internal
// registry, only verifies that it is legal ( e.g. either the
// ident number is not yet assigned, or it is assigned to
// matching signature text, and the signature text is not empty
// ).
//
bool cEventManager::VValidateType(
	EventType const & inType ) const{
	if ( 0 == inType.getStr().length() )
		return false;
	if ( ( inType.getHashValue() == 0 ) &&
		(strcmp(inType.getStr().c_str(),kpWildcardEventType) != 0) )
		return false;
	EventTypeSet::const_iterator evIt =
		m_typeList.find( inType );
	if ( evIt == m_typeList.end() ){
		printf("Event Failed validation: not registered with the EventManager!\n");
		return false;
	}

	return true;
}
开发者ID:remesnik,项目名称:SDLDecker,代码行数:25,代码来源:cEventManager.cpp

示例2: VAbortEvent

//
// EventManager::VAbortEvent			- Chapter 10, page 295
//
// Find the next-available instance of the named event type and
// remove it from the processing queue.
//
// This may be done up to the point that it is actively being
// processed ...  e.g.: is safe to happen during event processing
// itself.
//
// returns true if the event was found and removed, false
// otherwise
//
bool EventManager::VAbortEvent ( EventType const & inType,
											bool allOfType )
{
	assert ( m_activeQueue >= 0 );
	assert ( m_activeQueue < kNumQueues );

	if ( ! VValidateType( inType ) )
		return false;

	EventListenerMap::iterator it = m_registry.find( inType.getHashValue() );

	if ( it == m_registry.end() )
		return false; // no listeners for this event, skipit

	bool rc = false;

	// See a good discussion on this code here:
	// http://www.mcshaffry.com/GameCode/thread.php?threadid=517&sid=

	EventQueue &evtQueue = m_queues[m_activeQueue];

	for ( EventQueue::iterator it = evtQueue.begin(),
			  itEnd = evtQueue.end(); it != itEnd; it++ )
	{
		if ( (*it)->VGetEventType() == inType )
		{
			it = evtQueue.erase(it);
			rc = true;
			if ( !allOfType )
				break;
		}
		else
		{
			++it;
		}
	}

	return rc;
}
开发者ID:alanr74,项目名称:gamecode3,代码行数:52,代码来源:EventManagerImpl.cpp


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