org.jactr.modules.pm.common.efferent
Class EfferentCommandManager<C extends org.commonreality.efferent.IEfferentCommand>

java.lang.Object
  extended by org.jactr.modules.pm.common.efferent.EfferentCommandManager<C>
Type Parameters:
C -
Direct Known Subclasses:
MotorCommandManager, VocalCommandManager

public abstract class EfferentCommandManager<C extends org.commonreality.efferent.IEfferentCommand>
extends java.lang.Object

abstract class used to manage specific efferent commands.Extending this class will give you access to callbacks for the state changes of the commands. This manager allows you to create and submit new commands ( newCommand(IEfferentObject, Object...) request changes ( request(DeltaTracker, org.commonreality.efferent.IEfferentCommand.RequestedState) , execute and abort (execute(DeltaTracker) abort(DeltaTracker)), and upon completion (typically called from commandCompleted(IEfferentCommand) and #commandAborted(IEfferentCommand)), the ability to remove the command.

Author:
harrison

Constructor Summary
EfferentCommandManager(java.util.concurrent.Executor executor)
           
 
Method Summary
 java.util.concurrent.Future<C> abort(org.commonreality.object.delta.DeltaTracker<? extends org.commonreality.object.IMutableObject> commandChange)
          request that the command be aborted
 void clear()
          explicitly request that executing commands are aborted, and issue a remove for all the other commands.
 java.util.concurrent.Future<C> execute(org.commonreality.object.delta.DeltaTracker<? extends org.commonreality.object.IMutableObject> commandChange)
          request that the command be executed
 org.commonreality.agents.IAgent getAgent()
           
 C getCommand(org.commonreality.identifier.IIdentifier commandId)
           
 java.util.Set<org.commonreality.identifier.IIdentifier> getExecutingCommandIds(java.util.Set<org.commonreality.identifier.IIdentifier> container)
           
 java.util.Collection<C> getExecutingCommands(java.util.Collection<C> container)
          return all the commands that are currently executing
 org.commonreality.object.IEfferentObject getMuscle(org.commonreality.identifier.IIdentifier muscleId)
           
 void install(org.commonreality.agents.IAgent agent)
           
 boolean isAutoDeleteEnabled()
           
 boolean isExecuting()
           
 java.util.concurrent.Future<C> newCommand(org.commonreality.object.IEfferentObject object, java.lang.Object... parameters)
          create and submit a new command.
 void remove(C command)
          request removal
 void setAutoDeleteEnabled(boolean enabled)
           
 void uninstall(org.commonreality.agents.IAgent agent)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EfferentCommandManager

public EfferentCommandManager(java.util.concurrent.Executor executor)
Method Detail

install

public void install(org.commonreality.agents.IAgent agent)

uninstall

public void uninstall(org.commonreality.agents.IAgent agent)

getAgent

public org.commonreality.agents.IAgent getAgent()

getMuscle

public org.commonreality.object.IEfferentObject getMuscle(org.commonreality.identifier.IIdentifier muscleId)

getCommand

public C getCommand(org.commonreality.identifier.IIdentifier commandId)

isAutoDeleteEnabled

public boolean isAutoDeleteEnabled()

setAutoDeleteEnabled

public void setAutoDeleteEnabled(boolean enabled)

clear

public void clear()
explicitly request that executing commands are aborted, and issue a remove for all the other commands. All pending futures will return an IllegalStateException. No callbacks for active or pending commands will be called after this.


isExecuting

public final boolean isExecuting()

getExecutingCommandIds

public final java.util.Set<org.commonreality.identifier.IIdentifier> getExecutingCommandIds(java.util.Set<org.commonreality.identifier.IIdentifier> container)
Parameters:
container -
Returns:

getExecutingCommands

public final java.util.Collection<C> getExecutingCommands(java.util.Collection<C> container)
return all the commands that are currently executing

Parameters:
container -
Returns:

newCommand

public final java.util.concurrent.Future<C> newCommand(org.commonreality.object.IEfferentObject object,
                                                       java.lang.Object... parameters)
create and submit a new command. parameters will be passed on to createCommand(IEfferentObject, Object...) and can be used in anyway desired.
The future returned will block until an exception occurs, or the command is accepted or rejected.

Parameters:
object -
parameters -
Returns:

execute

public java.util.concurrent.Future<C> execute(org.commonreality.object.delta.DeltaTracker<? extends org.commonreality.object.IMutableObject> commandChange)
request that the command be executed

Parameters:
commandChange -
Returns:

abort

public java.util.concurrent.Future<C> abort(org.commonreality.object.delta.DeltaTracker<? extends org.commonreality.object.IMutableObject> commandChange)
request that the command be aborted

Parameters:
commandChange -
Returns:

remove

public final void remove(C command)
request removal

Parameters:
command -