View Javadoc

1   package cz.cuni.amis.pogamut.ut2004multi.communication.worldview;
2   
3   import com.google.inject.Inject;
4   import com.google.inject.name.Named;
5   
6   import cz.cuni.amis.pogamut.base.communication.mediator.IMediator;
7   import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldChangeEvent;
8   import cz.cuni.amis.pogamut.base.communication.worldview.object.event.WorldObjectFirstEncounteredEvent;
9   import cz.cuni.amis.pogamut.base.communication.worldview.object.event.WorldObjectUpdatedEvent;
10  import cz.cuni.amis.pogamut.base.component.controller.ComponentDependencies;
11  import cz.cuni.amis.pogamut.base.component.lifecyclebus.ILifecycleBus;
12  import cz.cuni.amis.pogamut.base.utils.guice.AgentScoped;
13  import cz.cuni.amis.pogamut.base.utils.logging.IAgentLogger;
14  import cz.cuni.amis.pogamut.multi.agent.ITeamedAgentId;
15  import cz.cuni.amis.pogamut.multi.communication.worldview.ISharedWorldView;
16  import cz.cuni.amis.pogamut.multi.communication.worldview.object.ILocalWorldObject;
17  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.BeginMessage;
18  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.EndMessage;
19  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Self;
20  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.SelfLocal;
21  
22  /**
23   * Implements the capability to recognize begin and end events and thus brings the capability to lock/unlock worldView. 
24   * @author srlok
25   *
26   */
27  @AgentScoped
28  public class UT2004LockableLocalWorldView extends UT2004VisionLocalWorldView {
29  
30  	@Inject
31  	public UT2004LockableLocalWorldView(
32  			@Named(WORLDVIEW_DEPENDENCY) ComponentDependencies dependencies,
33  			ILifecycleBus bus, IAgentLogger logger, IMediator mediator,
34  			ISharedWorldView parentWorldView, ITeamedAgentId agentId) {
35  		super(dependencies, bus, logger, parentWorldView, agentId);
36  		mediator.setConsumer(this);
37  	}
38  
39  	// because of SELF we have to override the objectUpdatedBehavior
40  	/*
41  	 * @Override protected void objectCreated(ILocalWorldObject obj, long
42  	 * simTime) { super.objectCreated(obj, simTime); }
43  	 * 
44  	 * @Override protected void objectUpdated(ILocalWorldObject obj, long
45  	 * simTime) { if (obj instanceof SelfLocal) { raiseEvent( new
46  	 * WorldObjectUpdatedEvent<Self>(this.getSingle(Self.class),
47  	 * getCurrentTimeKey().getTime()) ); } super.objectUpdated(obj, simTime); }
48  	 */
49  
50  	@Override
51  	protected boolean isBatchBeginEvent(IWorldChangeEvent event) {
52  		return event instanceof BeginMessage;
53  	}
54  
55  	@Override
56  	protected boolean isBatchEndEvent(IWorldChangeEvent event) {
57  		return event instanceof EndMessage;
58  	}
59  
60  }