Example #1
0
	const handler_ptr event_handlers::get_event_handler_by_id(const std::string & id) {
		id_map_t::iterator find_it = id_map_.find(id);
		if ( find_it != id_map_.end()  &&  !find_it->second.expired() ) {
			return handler_ptr( find_it->second );
		}
		return handler_ptr( );
	}
Example #2
0
/**
 * Dereference.
 * If the current element has become invalid, we will increment first.
 */
handler_ptr handler_list::iterator::operator*()
{
	// Check for an available handler.
	while ( iter_.derefable() ) {
		// Handler still accessible?
		if ( handler_ptr lock = iter_->lock() )
			return lock;
		else
			// Remove the now-defunct entry.
			iter_ = list_t::erase(iter_);
	}

	// End of the list.
	return handler_ptr();
}
Example #3
0
/**
 * Dereference
 * Will return a null pointer when the end of the iteration is reached.
 */
handler_ptr manager::iteration::operator*()
{
	// Get the candidate for the current element from the main list.
	handler_ptr main_ptr = *main_it_;
	handler_vec::size_type main_index = ptr_index(main_ptr);

	// Get the candidate for the current element from the var list.
	handler_ptr var_ptr = *var_it_;
	// (Loop while var_ptr would be chosen over main_ptr, but the name does not match.)
	while ( var_ptr  &&  var_ptr->index() < main_index  &&
	        !var_ptr->matches_name(event_name_, gamedata_) )
		var_ptr = *++var_it_;
	handler_vec::size_type var_index = ptr_index(var_ptr);

	// Which list? (Index ties go to the main list.)
	current_is_known_ = main_index < end_  ||  var_index < end_;
	main_is_current_ = main_index <= var_index;

	if ( !current_is_known_ )
		return handler_ptr(); // End of list; return a null pointer.
	else
		return main_is_current_ ? main_ptr : var_ptr;
}