se.liu.ida.critiquer.constraints
Class AgentMutex

java.lang.Object
  extended by se.liu.ida.critiquer.activities.AbstractParamChangedListener
      extended by se.liu.ida.critiquer.constraints.StandardConstraint
          extended by se.liu.ida.critiquer.constraints.StructureCritic
              extended by se.liu.ida.critiquer.constraints.AgentMutex
All Implemented Interfaces:
Serializable, Comparable<ActivityUpdateListener>, ActivityUpdateListener, SingletonConstraint, TextCritic, VisualConstraint, ViewRenderingListener

public class AgentMutex
extends StructureCritic
implements TextCritic

Checks whether or not an agent can be added to a commander, depending on if there are any other activities the agent is engaged in.

Author:
olale
See Also:
Serialized Form

Field Summary
 
Fields inherited from class se.liu.ida.critiquer.constraints.StructureCritic
applicableClasses, description, errorMessages, logger, OK
 
Fields inherited from class se.liu.ida.critiquer.constraints.StandardConstraint
applicableViews, statusListeners, violationActivities
 
Constructor Summary
AgentMutex()
          Create a new object unless there an AgentMutex has already been created.
 
Method Summary
 Pair<Boolean,String> check(Activity a)
          The activity parameter is null here since we are called from an AgentParameter which is not directly connected to an activity.
 String getDescription()
          Describe the critic
 String getName()
          Returns the name of the critic
static AgentMutex getSingleton()
           
 String getText()
          Returns the textual information that should be presented by this critic
 void viewUpdated(View v, Graphics2D g2)
           
 
Methods inherited from class se.liu.ida.critiquer.constraints.StructureCritic
activityCreated, activityRemoved, activityUpdated, addApplicableClass, addApplicableClasses, applicableForActivity, checkAndUpdate, compareTo, getErrorMessage, getErrorMessages, isConsistent, paramChanged
 
Methods inherited from class se.liu.ida.critiquer.constraints.StandardConstraint
addStatusListener, debug, error, getApplicableViews, getColor, info, initApplicableViews, isActive, isApplicableFor, isConsistent, removeStatusListener, setActive, setColor, setConsistent, warn
 
Methods inherited from class se.liu.ida.critiquer.activities.AbstractParamChangedListener
paramAdded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgentMutex

public AgentMutex()
Create a new object unless there an AgentMutex has already been created.

Method Detail

check

public Pair<Boolean,String> check(Activity a)
The activity parameter is null here since we are called from an AgentParameter which is not directly connected to an activity. However, we can use the Commander of the AgentParameter p to retrieve a list of activities for which the current selection of agents is about to be selected. If there is an overlap in time between any of them and the other activities to which these agents are already assigned, the check fails.

Specified by:
check in class StructureCritic
Parameters:
a - Activity that fired this event or null if this was a parameter not directly connected to an activity. It is of little interest here since we use the activities available through the Commander
p - The parameter that caused this event.
newValue - The new value that we are supposed to check.
Returns:

getDescription

public String getDescription()
Describe the critic

Specified by:
getDescription in interface SingletonConstraint
Specified by:
getDescription in class StructureCritic
Returns:
the description string
See Also:
SingletonConstraint.getDescription()

viewUpdated

public void viewUpdated(View v,
                        Graphics2D g2)
Specified by:
viewUpdated in interface ViewRenderingListener
Overrides:
viewUpdated in class StructureCritic

getText

public String getText()
Returns the textual information that should be presented by this critic

Specified by:
getText in interface TextCritic
See Also:
TextCritic.getText()

getSingleton

public static AgentMutex getSingleton()
Returns:
Returns the singleton.

getName

public String getName()
Returns the name of the critic

Specified by:
getName in class StructureCritic
Returns:
a string with the name
See Also:
StructureCritic.getName()