View Javadoc

1   package cz.cuni.amis.pogamut.multi.factory.guice;
2   
3   import cz.cuni.amis.pogamut.base.communication.connection.IWorldConnection;
4   import cz.cuni.amis.pogamut.base.factory.guice.GuiceAgentModule;
5   import cz.cuni.amis.pogamut.base.factory.guice.GuiceRemoteAgentModule;
6   import cz.cuni.amis.pogamut.base.utils.guice.AdaptableProvider;
7   import cz.cuni.amis.pogamut.multi.communication.worldview.ISharedWorldView;
8   import cz.cuni.amis.pogamut.multi.params.ITeamRemoteAgentParameters;
9   import cz.cuni.amis.utils.NullCheck;
10  
11  /**
12   * Module extending {@link GuiceRemoteAgentModule} for the purpose of remote agents (those communicating with the world using 
13   * {@link IWorldConnection}) that is using {@link ISharedWorldView} to synchronize information within the agent's team.
14   * <p><p>
15   * See {@link GuiceRemoteAgentModule} for more information.
16   * <p><p>
17   * This module introduces {@link GuiceTeamRemoteAgentModule#getSharedWorldViewProvider()} that is correctly filled during {@link GuiceTeamRemoteAgentModule#prepareNewAgent(ITeamRemoteAgentParameters)}
18   * and so it can be used during agent construction.
19   * 
20   * @see GuiceAgentModule
21   * @author Jimmy
22   */
23  public abstract class GuiceTeamRemoteAgentModule<PARAMS extends ITeamRemoteAgentParameters> extends GuiceRemoteAgentModule<PARAMS> {
24  	
25  	private AdaptableProvider<ISharedWorldView> sharedWorldViewProvider = new AdaptableProvider<ISharedWorldView>(null);
26  		
27  	public AdaptableProvider<ISharedWorldView> getSharedWorldViewProvider() {
28  		return sharedWorldViewProvider;
29  	}
30  
31  	@Override
32  	public void prepareNewAgent(PARAMS agentParameters) {
33  		super.prepareNewAgent(agentParameters);
34  		NullCheck.check(agentParameters.getSharedWorldView(), "agentParameters.getSharedWorldView()");
35  		sharedWorldViewProvider.set(agentParameters.getSharedWorldView());
36  	};
37  
38  }