Exemplo n.º 1
0
void CLoader::CLoaderListener::Handler(const IEventDispatcher::CEvent& Event)
{
	const CLoader::CLoadEvent& LoadEvent = static_cast<const CLoader::CLoadEvent&>(Event);
	const STRING& Path = LoadEvent.GetPath();
	CVector<UINT>* pIndices = m_IndexMap.Get( LoadEvent.GetPath() );
	if(pIndices)
	{
		UINT uIndex, uDestination = LoadEvent.GetIndex();
		CVector<UINT>::CIterator Iterator = pIndices->GetIterator(0);
		while( CVector<UINT>::IsValuable(Iterator) )
		{
			uIndex = *Iterator;
			if(uIndex < m_uDataCount)
			{
				if(!m_puDataIndices)
					ALCHEMY_DEBUG_NEW(m_puDataIndices, UINT[m_uDataCount]);

				m_puDataIndices[uIndex] = uDestination;

				++ m_uLoadedCount;
			}

			++ Iterator;
		}

		pIndices->Clear();
	}

	if(m_uLoadedCount == m_uDataCount)
	{
		IEventDispatcher* pEventDispatcher = Event.GetTarget();
		if(pEventDispatcher)
		{
			UINT uType;

			if( ALCHEMY_GET_EVENT_TYPE(uType, LOAD_ALL_COMPLETE, CLoader) )
			{
				CLoadAllEvent LoadAllEvent(m_puDataIndices, m_uDataCount, uType);

				pEventDispatcher->DispatchEvent(LoadAllEvent);
			}

			if( ALCHEMY_GET_EVENT_TYPE(uType, LOAD_COMPLETE, CLoader) )
				pEventDispatcher->RemoveEventListener(uType, *this);

			if( m_Parent.m_uFreeListenerCount < m_Parent.m_FreeListeners.GetLength() )
				m_Parent.m_FreeListeners.Set(this, m_Parent.m_uFreeListenerCount);
			else
				m_Parent.m_FreeListeners.Add(this);

			++ m_Parent.m_uFreeListenerCount;
		}
	}
}
Exemplo n.º 2
0
void CAcmUdp::GetAllDomains(CVector<uint32> &oDomains)
{
	oDomains.Clear();
	CRbTreeNode* pEnd = g_oUdpTable.End();
	g_oMutex.Enter();
	CRbTreeNode* pIt = g_oUdpTable.First();
	for(uint32 nIdx=0; pIt!=pEnd; pIt=g_oUdpTable.GetNext(pIt))
	{
		uint32 nDomain = g_oUdpTable.GetKey(pIt);
		oDomains.Insert(nIdx, nDomain);
		++nIdx;
	}
	g_oMutex.Leave();
}