View Javadoc

1   package cz.cuni.amis.pogamut.multi.params.impl;
2   
3   import cz.cuni.amis.pogamut.base.agent.IAgentId;
4   import cz.cuni.amis.pogamut.base.agent.params.IAgentParameters;
5   import cz.cuni.amis.pogamut.base.agent.params.impl.RemoteAgentParameters;
6   import cz.cuni.amis.pogamut.base.communication.connection.IWorldConnectionAddress;
7   import cz.cuni.amis.pogamut.multi.communication.worldview.ISharedWorldView;
8   import cz.cuni.amis.pogamut.multi.params.ITeamAgentParameters;
9   import cz.cuni.amis.pogamut.multi.params.ITeamRemoteAgentParameters;
10  
11  public class TeamRemoteAgentParameters<SHARED_WORLDVIEW extends ISharedWorldView> extends RemoteAgentParameters implements ITeamRemoteAgentParameters<SHARED_WORLDVIEW> {
12  
13  	protected SHARED_WORLDVIEW sharedWorldView;
14  	
15  	public TeamRemoteAgentParameters() {
16  		super();
17  		this.sharedWorldView = null;
18  	}
19  
20  	
21  	@Override
22  	public SHARED_WORLDVIEW getSharedWorldView() {
23  		return sharedWorldView;
24  	}
25  	
26  	/**
27  	 * Sets instance of {@link ISharedWorldView} that should be used by this agent.
28  	 * <p><p>
29  	 * WARNING: Note that you should not mess with 'setters' in different threads as they
30  	 * are non-thread-safe and may interrupt horribly agent instantiations with such behavior.
31  	 * 
32  	 * @param sharedWorldView
33  	 * @return this instance
34  	 */
35  	public TeamRemoteAgentParameters<SHARED_WORLDVIEW> setSharedWorldView(SHARED_WORLDVIEW sharedWorldView) {
36  		this.sharedWorldView = sharedWorldView;
37  		return this;
38  	}
39  	
40  	@Override
41  	public TeamRemoteAgentParameters<SHARED_WORLDVIEW> setAgentId(IAgentId agentId) {
42  		super.setAgentId(agentId);
43  		return this;
44  	}
45  	
46  	@Override
47  	public TeamRemoteAgentParameters<SHARED_WORLDVIEW> setWorldAddress(IWorldConnectionAddress address) {
48  		super.setWorldAddress(address);
49  		return this;
50  	}
51  	
52  	@Override
53  	public void assignDefaults(IAgentParameters defaults) {
54  		super.assignDefaults(defaults);
55  		if (defaults instanceof ITeamAgentParameters) {
56  			if (sharedWorldView == null) {
57  				sharedWorldView = (SHARED_WORLDVIEW) ((ITeamAgentParameters)defaults).getSharedWorldView();
58  			}
59  		}
60  	}
61  
62  }