コード例 #1
0
ファイル: VistaEventManager.cpp プロジェクト: HBPVIS/Vista
bool VistaEventManager::GetIsObserver(VistaEventObserver *pObserver, int iEventType) const
{
	if (IsValidEventType(iEventType))
	{
		OBSQUEUE *pO = m_veHandlerMapping[iEventType].second.second;
		if( std::find((*pO).begin(), (*pO).end(), pObserver) != (*pO).end() )
			return true;
	}
	return false;
}
コード例 #2
0
OP_STATUS
DOM_ApplicationCache::OnEvent(DOM_EventType event_type, BOOL lengthComputable, OpFileLength loaded, OpFileLength total)
{
	// Check that the event type is relevant to the application cache
	OP_ASSERT(IsValidEventType(event_type));

	DOM_Runtime* runtime = GetRuntime();
	OP_ASSERT(runtime);

	DOM_Event *event = NULL;
	if (event_type == ONPROGRESS)
	{
		RETURN_IF_ERROR(DOMSetObjectRuntime(event = OP_NEW(DOM_ApplicationCacheProgressEvent, ()), runtime, runtime->GetPrototype(DOM_Runtime::PROGRESSEVENT_PROTOTYPE), "ProgressEvent"));
		static_cast<DOM_ProgressEvent*>(event)->InitProgressEvent(lengthComputable, loaded, total);
	}
コード例 #3
0
ファイル: VistaEventManager.cpp プロジェクト: HBPVIS/Vista
int VistaEventManager::GetPriority(VistaEventHandler *pHandler,
				EVENTTYPE nEventType,
				EVENTID nEventId) const
{

	if(!IsValidEventType(nEventType) || nEventId == -1)
		return -1;

	HANQUEUE *pL = GetHandlerList(nEventType, nEventId);
	if(pL == NULL)
		return -1;

	HANQUEUE::const_iterator cit = std::find((*pL).begin(), (*pL).end(), HANDLER(-1, pHandler));
	if(cit == (*pL).end())
		return -1;

	return (*cit).m_nPrio;
}
コード例 #4
0
ファイル: VistaEventManager.cpp プロジェクト: HBPVIS/Vista
bool VistaEventManager::SetPriority(VistaEventHandler *pHandler,
				EVENTTYPE nEventType,
				EVENTID nEventId,
				int nPriority)
{
	if(!IsValidEventType(nEventType) || nEventId == -1)
		return false;

	HANQUEUE *pL = GetHandlerList(nEventType, nEventId);
	if(pL == NULL)
		return false;

	HANQUEUE::iterator cit = std::find((*pL).begin(), (*pL).end(), HANDLER(-1, pHandler));
	if(cit == (*pL).end())
		return false;

	(*cit).m_nPrio = nPriority;
	(*pL).sort(_qCompPrio());


	return true;
}
コード例 #5
0
ファイル: VistaEventManager.cpp プロジェクト: HBPVIS/Vista
/*============================================================================*/
bool VistaEventManager::ProcessEvent( VistaEvent *pEvent )
{
	// make sure, we do have a valid event
	if( pEvent == NULL )
	{
		vstr::warnp() << "[ViEvMa] received NULL event pointer" << std::endl;
		return false;
	}

	// find proper mapping
	int iEventType = pEvent->GetType();

	// Is the event itself valid?
	if( !IsValidEventType( iEventType ) )
	{
		vstr::warni() << "[ViEvMa] received invalid event - event type: "
					<< pEvent->GetType() << std::endl;
		return false;
	}

	// increase recursion counter
	++m_iProcessRecursionCount;
	
	pEvent->m_nCount = ++m_nEventCount;

	// set some data members of the event
	pEvent->m_bHandled = false;

	if( m_bResetEventTimeToLocalTime )
		pEvent->m_nTime = VistaTimeUtils::GetStandardTimer().GetSystemTime();

	// find event handler for this type
	HANP &hp = m_veHandlerMapping[iEventType];
	int nEvId = pEvent->GetId();


	// notify observers first
	OBSQUEUE *pO = hp.second.second;
	for( OBSQUEUE::const_iterator cit = (*pO).begin();
		cit != (*pO).end(); ++cit )
	{
		if(!(*cit)->m_bIsDef)
			(*cit)->Notify(pEvent);
	}


	if(nEvId < (int)hp.second.first.size())
	{
		HANQUEUE *q = hp.second.first[nEvId].second;
		for(HANQUEUE::iterator it = (*q).begin(); it != (*q).end(); ++it)
		{
			if((*it).m_pHandler->GetIsEnabled())
			{
				(*it).m_pHandler->HandleEvent(pEvent);

				// check, if event was consumed
				if(pEvent->IsHandled())
					break; // leave loop
			}
		}
	}

	// ok, we are done, decrease recursion count
	--m_iProcessRecursionCount;

	// in case we are at the top-level call to ProcessEvent, we can
	// compute the new observer lists, but only iff there was any
	// change at all
	if((m_iProcessRecursionCount == 0) && m_bObserverQueueDirty)
		HandleObserverQueueChange();

	// indicate success to caller
	return pEvent->IsHandled();
}