|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.pogamut.ut2004multi.communication.module.SharedKnowledgeDatabase
public class SharedKnowledgeDatabase
Manages shared knowledge for agent teams.
The class is managed - meaning only one instance can exist for each team.
Beware that this class can only be used when you are running all your agents from a single JVM.
This means you have to used the new MultipleAgentRunner
to run your team. Then each agent has to register with this
database by calling addAgent(IAgentId, IVisionWorldView, int)
with the specific parameters.
After that, the database should be ready for use.
Field Summary | |
---|---|
protected cz.cuni.amis.utils.concurrency.AtomicLongList |
agentLockTimes
agentLockTimes[agentNumber] == lock time the agent owns (or -1 for no-lock) |
protected Map<IAgentId,IVisionWorldView> |
agentWorldViews
Maps the agentIds to their concrete worldViews - these are then used in getting the local object information and to attach the listeners |
protected Map<IAgentId,TimeKey> |
currentTimeKeys
The current TimeKey handled by an agent |
protected cz.cuni.amis.utils.maps.HashMapMap<WorldObjectId,PropertyId,ISharedProperty> |
currSharedProperties
The most recent versions of sharedProperties |
protected HashMap<TimeKey,Set<IAgentId>> |
heldKeys
Currently 'locked' timeKeys (with agents locking the keys) - we need to keep objects for those |
protected static Map<Integer,SharedKnowledgeDatabase> |
instances
Team number to instance. |
protected Map<WorldObjectId,Long> |
lastUpdateTime
Holds the last time when an update event was recieved from any agent for each object |
protected Map<IAgentId,Set<IWorldObjectEventListener>> |
listeners
Remembers all the listeners added for an agent, this is needed to properly remove them when a agent unregisters from the database |
protected cz.cuni.amis.utils.maps.SyncHashMap<IAgentId,Integer> |
registeredAgents
Which agents are registered here mapped to their agent-numbers. |
protected Set<Class> |
registeredClasses
Classes for which the database processes events |
protected cz.cuni.amis.utils.maps.WeakHashTriMap<TimeKey,WorldObjectId,PropertyId,ISharedProperty> |
sharedProperties
Just holds the weakly referenced shared properties for the worldObjects |
protected int |
team
Team number for which the shared knowledge database was constructed for. |
Constructor Summary | |
---|---|
protected |
SharedKnowledgeDatabase(int team)
|
Method Summary | |
---|---|
void |
addAgent(IAgentId id,
IVisionWorldView agentWorldView,
int team)
Registers an agent to the database - it will process it's relevant events from now on. |
protected void |
addClassListener(IVisionWorldView wv,
Class c,
IAgentId agentId)
Helper method to add a single objectEventListener for Class c to a specific WorldView |
void |
addObjectClass(Class c)
Registers the provided class as a class of interest. |
protected void |
addTimeLock(TimeKey timeKey,
IAgentId id)
Locks the specified time and all greater times with the agentId |
static SharedKnowledgeDatabase |
get(int team)
Returns the only instance of SharedKnowledgeDatabase for the specified team. |
IWorldObject |
getObject(WorldObjectId id,
IAgentId agentId)
Returns the specified object with the team shared knowledge put in |
protected void |
processObjEvent(IWorldObjectEvent<IWorldObject> event,
IAgentId agentId)
Handles processing of an object event raised on any of the worldViews. |
boolean |
removeAgent(IAgentId id)
Unregister the agent from the database -> the database will no longer process events from this agent. |
boolean |
removeObjectClass(Class c)
Stops processing events for the specified class. |
protected void |
removeTimeLock(TimeKey timeKey,
IAgentId id)
Removes a single lock for this timeKey, if it is the last, the whole lock is removed |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static Map<Integer,SharedKnowledgeDatabase> instances
protected cz.cuni.amis.utils.maps.SyncHashMap<IAgentId,Integer> registeredAgents
protected int team
protected cz.cuni.amis.utils.concurrency.AtomicLongList agentLockTimes
protected Map<IAgentId,IVisionWorldView> agentWorldViews
protected Map<IAgentId,Set<IWorldObjectEventListener>> listeners
protected cz.cuni.amis.utils.maps.WeakHashTriMap<TimeKey,WorldObjectId,PropertyId,ISharedProperty> sharedProperties
protected cz.cuni.amis.utils.maps.HashMapMap<WorldObjectId,PropertyId,ISharedProperty> currSharedProperties
protected Map<WorldObjectId,Long> lastUpdateTime
protected HashMap<TimeKey,Set<IAgentId>> heldKeys
protected Map<IAgentId,TimeKey> currentTimeKeys
protected Set<Class> registeredClasses
Constructor Detail |
---|
protected SharedKnowledgeDatabase(int team)
Method Detail |
---|
public static SharedKnowledgeDatabase get(int team)
team
-
protected void addTimeLock(TimeKey timeKey, IAgentId id)
protected void removeTimeLock(TimeKey timeKey, IAgentId id)
timeKey
- id
- public void addAgent(IAgentId id, IVisionWorldView agentWorldView, int team)
id
- agentWorldView
- team
- public void addObjectClass(Class c)
c
- public boolean removeObjectClass(Class c)
c
- class to process events for
public boolean removeAgent(IAgentId id)
id
- team
-
public IWorldObject getObject(WorldObjectId id, IAgentId agentId)
id
- agentId
-
protected void addClassListener(IVisionWorldView wv, Class c, IAgentId agentId)
wv
- c
- agentId
- protected void processObjEvent(IWorldObjectEvent<IWorldObject> event, IAgentId agentId)
event
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |