|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.pogamut.multi.communication.worldview.impl.LocalWorldViewAdapter
public class LocalWorldViewAdapter
This class serves as an adapter for ILocalWorldView to satisfy the IWorldView interface, all methods of this worldView only call the appropriate methods on the backing localWorldView
Constructor Summary | |
---|---|
LocalWorldViewAdapter(BatchAwareLocalWorldView localWV)
|
Method Summary | ||
---|---|---|
void |
addEventListener(Class<?> eventClass,
IWorldEventListener<?> listener)
Adds listener to a specific event (Level A listeners). |
|
void |
addObjectListener(Class<?> objectClass,
Class<?> eventClass,
IWorldObjectEventListener<?,?> listener)
Adds listener to a specified 'event' that occurs on the specific 'objectClass' (Level C listeners). |
|
void |
addObjectListener(Class<?> objectClass,
IWorldObjectEventListener<?,?> listener)
Adds listener to all events that happens on any object of the 'objectClass' (Level B listeners). |
|
void |
addObjectListener(WorldObjectId objectId,
Class<?> eventClass,
IWorldObjectEventListener<?,?> listener)
Adds listener to a specified 'event' that occurs on the specific object with 'objectId' (Level E listeners). |
|
void |
addObjectListener(WorldObjectId objectId,
IWorldObjectEventListener<?,?> listener)
Adds listener to all events that happens on object with specific 'objectId' (Level D listeners). |
|
Map<WorldObjectId,IWorldObject> |
get()
Returns map with objects inserted according to their id. |
|
IWorldObject |
get(WorldObjectId id)
Returns a world object of the specific id (if exists inside the world view). |
|
|
get(WorldObjectId objectId,
Class<T> clazz)
Returns a world object of the specific id and class (if exists inside the world view). |
|
Map<Class,Map<WorldObjectId,IWorldObject>> |
getAll()
Returns map of all objects that are present in the world view. |
|
|
getAll(Class<T> type)
Returns map of all objects of a specific type that are present in the world view. |
|
Map<Class,Map<WorldObjectId,IViewable>> |
getAllVisible()
Returns map of all visible objects ( IViewable instances} - those that the agent can currently see. |
|
|
getAllVisible(Class<T> type)
Returns map of all visible objects ( IViewable instances} - those that the agent can currently see. |
|
cz.cuni.amis.utils.token.IToken |
getComponentId()
Unique identification of the component. |
|
IComponentBus |
getEventBus()
|
|
long |
getSimTime()
|
|
|
getSingle(Class<T> cls)
Returns the only instance of required object if present, if there are more instances of this object then IllegalArgumentException will be thrown. |
|
Map<WorldObjectId,IViewable> |
getVisible()
Returns map of all visible objects ( IViewable instances} organized according to their WorldObjectId -
those that the agent can currently see. |
|
IViewable |
getVisible(WorldObjectId id)
Returns a visible world object of the specific id (if exists inside the world view and is visible). |
|
boolean |
isListening(Class<?> objectClass,
Class<?> eventClass,
IWorldObjectEventListener<?,?> listener)
Tests whether the 'listener' is listening at specified 'objectClass' for specified 'event' (Level C listeners). |
|
boolean |
isListening(Class<?> eventClass,
IWorldEventListener<?> listener)
Tests whether the 'listener' is listening to a specific event (Level A listeners). |
|
boolean |
isListening(Class<?> objectClass,
IWorldObjectEventListener<?,?> listener)
Tests whether the 'listener' is listening at specified 'objectClass' (Level B listeners). |
|
boolean |
isListening(IWorldEventListener<?> listener)
Checks whether this listener is hooked to the world view (at any listener level). |
|
boolean |
isListening(WorldObjectId objectId,
Class<?> eventClass,
IWorldObjectEventListener<?,?> listener)
Tests whether the 'listener' is listening to a specified 'event' that occurs on the specific object with 'objectId' (Level E listeners). |
|
boolean |
isListening(WorldObjectId objectId,
IWorldObjectEventListener<?,?> listener)
Tests whether the 'listener' is listening at specified 'objectId' (Level D Listeners). |
|
boolean |
isLocked()
Whether the worldview is locked. |
|
void |
lock()
Lock the worldview, preventing it from raising any new events. |
|
void |
notify(IWorldChangeEvent event)
New event was generated from the world. |
|
void |
notifyAfterPropagation(IWorldChangeEvent event)
Raise another event after current one finishes its propagation. |
|
void |
notifyImmediately(IWorldChangeEvent event)
Notify immediately will process the event right away, it won't use "event recursion buffer" to postpone the processing of the event. |
|
void |
removeEventListener(Class<?> eventClass,
IWorldEventListener<?> listener)
Removes listener from a specific event (Level A listeners). |
|
void |
removeListener(IWorldEventListener<?> listener)
Removes listener from every listeners category (from every listener level). |
|
void |
removeObjectListener(Class<?> objectClass,
Class<?> eventClass,
IWorldObjectEventListener<?,?> listener)
Removes listener from specific 'objectClass' listening for specified 'event' (Level C listeners). |
|
void |
removeObjectListener(Class<?> objectClass,
IWorldObjectEventListener<?,?> listener)
Removes listener from specific 'objectClass' listening for specified 'event' (Level B listeners). |
|
void |
removeObjectListener(WorldObjectId objectId,
Class<?> eventClass,
IWorldObjectEventListener<?,?> listener)
Removes listener to a specified 'event' that occurs on the specific object with 'objectId' (Level E listeners). |
|
void |
removeObjectListener(WorldObjectId objectId,
IWorldObjectEventListener<?,?> listener)
Removes listener from objects with specified 'objectId' (Level D Listeners). |
|
void |
unlock()
Unlock the worldview, processing all events that came between lock() / unlock() calls. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@Inject public LocalWorldViewAdapter(BatchAwareLocalWorldView localWV)
Method Detail |
---|
public long getSimTime()
public void notify(IWorldChangeEvent event) throws ComponentNotRunningException, ComponentPausedException
IWorldChangeEventInput
notify
in interface IWorldChangeEventInput
ComponentNotRunningException
ComponentPausedException
public void notifyAfterPropagation(IWorldChangeEvent event) throws ComponentNotRunningException, ComponentPausedException
IWorldChangeEventInput
Won't propagate the event if the world view is locked!.
notifyAfterPropagation
in interface IWorldChangeEventInput
ComponentNotRunningException
ComponentPausedException
public void notifyImmediately(IWorldChangeEvent event) throws ComponentNotRunningException, ComponentPausedException
IWorldChangeEventInput
This will work even if the world view is locked!
notifyImmediately
in interface IWorldChangeEventInput
ComponentNotRunningException
ComponentPausedException
public cz.cuni.amis.utils.token.IToken getComponentId()
IComponent
getComponentId
in interface IComponent
public IComponentBus getEventBus()
getEventBus
in interface IWorldView
public void addEventListener(Class<?> eventClass, IWorldEventListener<?> listener)
IWorldView
It is the most general type of listener-registration allowing you to sniff any type of events.
Events passed to the listener are filtered only according to the 'event' class.
WARNING: even though the method does not require templated class and listener, you must be sure that 'listener' can accept 'eventClass'.
addEventListener
in interface IWorldView
eventClass
- which event types you want to receivelistener
- where you want to handle these eventspublic void addObjectListener(Class<?> objectClass, IWorldObjectEventListener<?,?> listener)
IWorldView
Events passed to the listener are filtered according to the 'objectClass'.
WARNING: even though the method does not require templated classes and listener, you must be sure that 'listener' accepts all events (IWorldObjectEvent) for objects of 'objectClass'.
addObjectListener
in interface IWorldView
objectClass
- which object class you want to listen atlistener
- where you want to handle these eventspublic void addObjectListener(Class<?> objectClass, Class<?> eventClass, IWorldObjectEventListener<?,?> listener)
IWorldView
Events passed to the listener are filtered according to the 'event' and 'objectClass' of the object the event happened upon.
WARNING: even though the method does not require templated classes and listener, you must be sure that 'listener' accepts 'eventClass' for objects of 'objectClass'.
eventClass can be any implementor of IWorldObjectEvent
. E.g.
WorldObjectAppearedEvent
, WorldObjectDestroyedEvent
, WorldObjectDisappearedEvent
,
WorldObjectFirstEncounteredEvent
or WorldObjectUpdatedEvent
.
addObjectListener
in interface IWorldView
objectClass
- which object class you want to listen ateventClass
- which event class you want to receivelistener
- where you want to handle these eventspublic void addObjectListener(WorldObjectId objectId, IWorldObjectEventListener<?,?> listener)
IWorldView
Events passed to the listener are filtered according to the 'objectId' of the object.
WARNING: you must ensure that 'listener' can accept the event raised on object of specified 'objectId'.
addObjectListener
in interface IWorldView
objectId
- which object you want to listen atlistener
- where you want to handle eventspublic void addObjectListener(WorldObjectId objectId, Class<?> eventClass, IWorldObjectEventListener<?,?> listener)
IWorldView
Events passed to the listener are filtered according to the 'event' and 'objectId' of the object.
WARNING: even though the method does not require templated classes and listener, you must be sure that 'listener' accepts 'eventClass' for objects of specified 'objectId'.
addObjectListener
in interface IWorldView
objectId
- which object you want to listen ateventClass
- which event classes you want to receivelistener
- where you want to handle these eventspublic void removeEventListener(Class<?> eventClass, IWorldEventListener<?> listener)
IWorldView
removeEventListener
in interface IWorldView
eventClass
- which events class you want to remove the listener fromlistener
- you want to removepublic void removeObjectListener(Class<?> objectClass, IWorldObjectEventListener<?,?> listener)
IWorldView
removeObjectListener
in interface IWorldView
objectClass
- class of objects you want the listener to remove fromlistener
- you want to removepublic void removeObjectListener(Class<?> objectClass, Class<?> eventClass, IWorldObjectEventListener<?,?> listener)
IWorldView
removeObjectListener
in interface IWorldView
objectClass
- class of objects you want the listener to remove fromeventClass
- which events class you want to remove the listener fromlistener
- you want to removepublic void removeObjectListener(WorldObjectId objectId, IWorldObjectEventListener<?,?> listener)
IWorldView
removeObjectListener
in interface IWorldView
objectId
- id of object you want the listener to remove fromlistener
- you want to removepublic void removeObjectListener(WorldObjectId objectId, Class<?> eventClass, IWorldObjectEventListener<?,?> listener)
IWorldView
removeObjectListener
in interface IWorldView
objectId
- id of object you want the listener to remove fromeventClass
- event class you want to stop receiving in the listenerlistener
- you want to removepublic void removeListener(IWorldEventListener<?> listener)
IWorldView
WARNING: Can be time consuming! (Iterating through all levels of listeners.)
removeListener
in interface IWorldView
listener
- you want to remove from all listener levelspublic boolean isListening(Class<?> eventClass, IWorldEventListener<?> listener)
IWorldView
isListening
in interface IWorldView
eventClass
- which events you want to receivelistener
- that is tested
public boolean isListening(Class<?> objectClass, IWorldObjectEventListener<?,?> listener)
IWorldView
isListening
in interface IWorldView
objectClass
- where the listener is testedlistener
- that is tested
public boolean isListening(Class<?> objectClass, Class<?> eventClass, IWorldObjectEventListener<?,?> listener)
IWorldView
isListening
in interface IWorldView
objectClass
- where the listener is testedeventClass
- where the listener is testedlistener
- that is tested
public boolean isListening(WorldObjectId objectId, IWorldObjectEventListener<?,?> listener)
IWorldView
isListening
in interface IWorldView
objectId
- where the listener is testedlistener
- that is tested
public boolean isListening(WorldObjectId objectId, Class<?> eventClass, IWorldObjectEventListener<?,?> listener)
IWorldView
isListening
in interface IWorldView
objectId
- where the listener is testedeventClass
- what class is testedlistener
- that is tested
public boolean isListening(IWorldEventListener<?> listener)
IWorldView
WARNING: Can be time consuming! (Iterating through all levels of listeners.)
isListening
in interface IWorldView
public Map<Class,Map<WorldObjectId,IWorldObject>> getAll()
IWorldView
WARNING: If you will do iteration over the map, you must synchronize on it.
getAll
in interface IWorldView
public <T extends IWorldObject> Map<WorldObjectId,T> getAll(Class<T> type)
IWorldView
WARNING: If you will do iteration over the map, you must synchronize on it.
getAll
in interface IWorldView
public <T extends IWorldObject> T getSingle(Class<T> cls)
IWorldView
IllegalArgumentException
will be thrown.
Should be used to obtain "utility" world objects such us "informations about the agent" (that is unique for the agent and as the world view should be used by only one agent...) or some "world statistics object".
getSingle
in interface IWorldView
cls
- Class of object to be retrieved
public Map<WorldObjectId,IWorldObject> get()
IWorldView
WARNING: If you will do iteration over the map, you must synchronize on it.
Note that this map contains various objects, therefore you will somehow guess the correct class of the object from its id.
get
in interface IWorldView
public IWorldObject get(WorldObjectId id)
IWorldView
Note that there is no way to tell the correct type of returned object - you have to cast it to a correct class yourself.
get
in interface IWorldView
id
- objects's id
public <T extends IWorldObject> T get(WorldObjectId objectId, Class<T> clazz)
IWorldView
get
in interface IWorldView
objectId
- objects's idclazz
- the class of the object to be returned
public Map<Class,Map<WorldObjectId,IViewable>> getAllVisible()
IVisionWorldView
IViewable
instances} - those that the agent can currently see.
WARNING: If you will do iteration over the map, you must synchronize on it.
getAllVisible
in interface IVisionWorldView
public <T extends IViewable> Map<WorldObjectId,T> getAllVisible(Class<T> type)
IVisionWorldView
IViewable
instances} - those that the agent can currently see.
WARNING: If you will do iteration over the map, you must synchronize on it.
getAllVisible
in interface IVisionWorldView
public Map<WorldObjectId,IViewable> getVisible()
IVisionWorldView
IViewable
instances} organized according to their WorldObjectId
-
those that the agent can currently see.
WARNING: If you will do iteration over the map, you must synchronize on it.
getVisible
in interface IVisionWorldView
public IViewable getVisible(WorldObjectId id)
IVisionWorldView
Otherwise, null is returned.
getVisible
in interface IVisionWorldView
id
- objects's id
public void lock() throws cz.cuni.amis.utils.exception.PogamutInterruptedException, ComponentNotRunningException, ComponentPausedException
ILockableWorldView
When locked - the worldview must store all incoming events and process them during unlock.
Note that it is implementation-dependent whether this method is blocking or not.
lock
in interface ILockableWorldView
cz.cuni.amis.utils.exception.PogamutInterruptedException
ComponentNotRunningException
ComponentPausedException
public void unlock() throws ComponentNotRunningException, ComponentPausedException
ILockableWorldView
unlock
in interface ILockableWorldView
ComponentNotRunningException
ComponentPausedException
public boolean isLocked()
ILockableWorldView
isLocked
in interface ILockableWorldView
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |