本文整理汇总了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;
}
示例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;
}