示例#1
0
void 
TransDispatcher::Subscribe( ushort type, ActionPtr action )
{
	K_ASSERT( type > 0 );
	K_ASSERT( action.Get() != 0 );

	ActionMap::iterator i( m_actions.find( type ) );

	if ( i == m_actions.end() )
	{
		ActionList lst;

		lst.push_back( action );

		m_actions.insert( ActionMap::value_type( type, lst ) );
	}
	else
	{
		ActionList& lst = i->second;

		lst.push_back( action );
	}
}
示例#2
0
void 
TransDispatcher::Dispatch( Transaction* trans )
{
	ActionMap::iterator i( m_actions.find( trans->GetType() ) );

	if ( i != m_actions.end() )
	{
		ActionList& lst = i->second;

		ActionList::iterator ai( lst.begin() );

		for ( ; ai != lst.end(); ++ai )
		{
			ActionPtr action = *ai;

			K_ASSERT( action.Get() != 0 );

			if ( !action->IsFinished() )
			{
				action->Completed( trans );
			}
		}
	}
}